diff options
-rw-r--r-- | security/coreconf/SunOS5.5.1_i86pc.mk | 46 | ||||
-rw-r--r-- | security/coreconf/SunOS5.6_i86pc.mk | 46 | ||||
-rw-r--r-- | security/coreconf/SunOS5.7_i86pc.mk | 48 | ||||
-rw-r--r-- | security/coreconf/SunOS5.8_i86pc.mk | 48 | ||||
-rwxr-xr-x | security/coreconf/SunOS5.9_i86pc.mk | 48 | ||||
-rw-r--r-- | security/coreconf/config.mk | 150 | ||||
-rw-r--r-- | security/coreconf/tree.mk | 114 | ||||
-rw-r--r-- | security/nss/lib/certdb/crl.c | 398 | ||||
-rw-r--r-- | security/nss/lib/freebl/Makefile | 342 | ||||
-rw-r--r-- | security/nss/lib/freebl/mpi/mpi_i86pc.s | 342 |
10 files changed, 1582 insertions, 0 deletions
diff --git a/security/coreconf/SunOS5.5.1_i86pc.mk b/security/coreconf/SunOS5.5.1_i86pc.mk new file mode 100644 index 000000000..a8a111dde --- /dev/null +++ b/security/coreconf/SunOS5.5.1_i86pc.mk @@ -0,0 +1,46 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# Config stuff for Solaris 2.5.1 on x86 +# + +SOL_CFLAGS = -D_SVID_GETTOD + +include $(CORE_DEPTH)/coreconf/SunOS5.mk + +CPU_ARCH = x86 +ARCHFLAG = +OS_DEFINES += -Di386 + +ifeq ($(OS_RELEASE),5.5.1_i86pc) + OS_DEFINES += -DSOLARIS2_5 +endif diff --git a/security/coreconf/SunOS5.6_i86pc.mk b/security/coreconf/SunOS5.6_i86pc.mk new file mode 100644 index 000000000..763c6810f --- /dev/null +++ b/security/coreconf/SunOS5.6_i86pc.mk @@ -0,0 +1,46 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# Config stuff for Solaris 2.6 on x86 +# + +SOL_CFLAGS = -D_SVID_GETTOD + +include $(CORE_DEPTH)/coreconf/SunOS5.mk + +CPU_ARCH = x86 +ARCHFLAG = +OS_DEFINES += -Di386 + +ifeq ($(OS_RELEASE),5.6_i86pc) + OS_DEFINES += -DSOLARIS2_6 +endif diff --git a/security/coreconf/SunOS5.7_i86pc.mk b/security/coreconf/SunOS5.7_i86pc.mk new file mode 100644 index 000000000..6ece4defb --- /dev/null +++ b/security/coreconf/SunOS5.7_i86pc.mk @@ -0,0 +1,48 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# Config stuff for Solaris 7 on x86 +# + +SOL_CFLAGS = -D_SVID_GETTOD + +include $(CORE_DEPTH)/coreconf/SunOS5.mk + +CPU_ARCH = x86 +ARCHFLAG = +OS_DEFINES += -Di386 + +ifeq ($(OS_RELEASE),5.7_i86pc) + OS_DEFINES += -DSOLARIS2_7 +endif + +OS_LIBS += -lthread -lnsl -lsocket -lposix4 -ldl -lc diff --git a/security/coreconf/SunOS5.8_i86pc.mk b/security/coreconf/SunOS5.8_i86pc.mk new file mode 100644 index 000000000..58b66b503 --- /dev/null +++ b/security/coreconf/SunOS5.8_i86pc.mk @@ -0,0 +1,48 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# Config stuff for Solaris 8 on x86 +# + +SOL_CFLAGS = -D_SVID_GETTOD + +include $(CORE_DEPTH)/coreconf/SunOS5.mk + +CPU_ARCH = x86 +ARCHFLAG = +OS_DEFINES += -Di386 + +ifeq ($(OS_RELEASE),5.8_i86pc) + OS_DEFINES += -DSOLARIS2_8 +endif + +OS_LIBS += -lthread -lnsl -lsocket -lposix4 -ldl -lc diff --git a/security/coreconf/SunOS5.9_i86pc.mk b/security/coreconf/SunOS5.9_i86pc.mk new file mode 100755 index 000000000..8ad8d0ba5 --- /dev/null +++ b/security/coreconf/SunOS5.9_i86pc.mk @@ -0,0 +1,48 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# Config stuff for Solaris 9 on x86 +# + +SOL_CFLAGS = -D_SVID_GETTOD + +include $(CORE_DEPTH)/coreconf/SunOS5.mk + +CPU_ARCH = x86 +ARCHFLAG = +OS_DEFINES += -Di386 + +ifeq ($(OS_RELEASE),5.9_i86pc) + OS_DEFINES += -DSOLARIS2_9 +endif + +OS_LIBS += -lthread -lnsl -lsocket -lposix4 -ldl -lc diff --git a/security/coreconf/config.mk b/security/coreconf/config.mk new file mode 100644 index 000000000..9e606f2d5 --- /dev/null +++ b/security/coreconf/config.mk @@ -0,0 +1,150 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# Configuration information for building in the "Core Components" source module +# + +####################################################################### +# [1.0] Master "Core Components" source and release <architecture> # +# tags # +####################################################################### + +include $(CORE_DEPTH)/coreconf/arch.mk + +####################################################################### +# [2.0] Master "Core Components" default command macros # +# (NOTE: may be overridden in $(OS_CONFIG).mk) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/command.mk + +####################################################################### +# [3.0] Master "Core Components" <architecture>-specific macros # +# (dependent upon <architecture> tags) # +# # +# We are moving towards just having a $(OS_TARGET).mk file # +# as opposed to multiple $(OS_CONFIG).mk files, one for # +# each OS release. # +####################################################################### + +ifeq (,$(filter-out FreeBSD BSD_OS NetBSD OS2,$(OS_TARGET))) +include $(CORE_DEPTH)/coreconf/$(OS_TARGET).mk +else +include $(CORE_DEPTH)/coreconf/$(OS_CONFIG).mk +endif + +####################################################################### +# [4.0] Master "Core Components" source and release <platform> tags # +# (dependent upon <architecture> tags) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/platform.mk + +####################################################################### +# [5.0] Master "Core Components" release <tree> tags # +# (dependent upon <architecture> tags) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/tree.mk + +####################################################################### +# [6.0] Master "Core Components" source and release <component> tags # +# NOTE: A component is also called a module or a subsystem. # +# (dependent upon $(MODULE) being defined on the # +# command line, as an environment variable, or in individual # +# makefiles, or more appropriately, manifest.mn) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/module.mk + +####################################################################### +# [7.0] Master "Core Components" release <version> tags # +# (dependent upon $(MODULE) being defined on the # +# command line, as an environment variable, or in individual # +# makefiles, or more appropriately, manifest.mn) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/version.mk + +####################################################################### +# [8.0] Master "Core Components" macros to figure out # +# binary code location # +# (dependent upon <platform> tags) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/location.mk + +####################################################################### +# [9.0] Master "Core Components" <component>-specific source path # +# (dependent upon <user_source_tree>, <source_component>, # +# <version>, and <platform> tags) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/source.mk + +####################################################################### +# [10.0] Master "Core Components" include switch for support header # +# files # +# (dependent upon <tree>, <component>, <version>, # +# and <platform> tags) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/headers.mk + +####################################################################### +# [11.0] Master "Core Components" for computing program prefixes # +####################################################################### + +include $(CORE_DEPTH)/coreconf/prefix.mk + +####################################################################### +# [12.0] Master "Core Components" for computing program suffixes # +# (dependent upon <architecture> tags) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/suffix.mk + +####################################################################### +# [13.0] Master "Core Components" for defining JDK # +# (dependent upon <architecture>, <source>, and <suffix> tags)# +####################################################################### + +include $(CORE_DEPTH)/coreconf/jdk.mk + +####################################################################### +# [14.0] Master "Core Components" rule set # +# (should always be the last file included by config.mk) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/ruleset.mk +-include $(MKDEPENDENCIES) + diff --git a/security/coreconf/tree.mk b/security/coreconf/tree.mk new file mode 100644 index 000000000..ae391b7ef --- /dev/null +++ b/security/coreconf/tree.mk @@ -0,0 +1,114 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# + +####################################################################### +# Master "Core Components" file system "release" prefixes # +####################################################################### + +# RELEASE_TREE = $(CORE_DEPTH)/../coredist + + +ifndef RELEASE_TREE + ifdef BUILD_SHIP + ifdef USE_SHIPS + RELEASE_TREE = $(BUILD_SHIP) + else + RELEASE_TREE = /share/builds/components + endif + else + RELEASE_TREE = /share/builds/components + endif + ifeq ($(OS_TARGET), WINNT) + ifdef BUILD_SHIP + ifdef USE_SHIPS + RELEASE_TREE = $(NTBUILD_SHIP) + else + RELEASE_TREE = //blds-sca15a/components + endif + else + RELEASE_TREE = //blds-sca15a/components + endif + endif + + ifeq ($(OS_TARGET), WIN95) + ifdef BUILD_SHIP + ifdef USE_SHIPS + RELEASE_TREE = $(NTBUILD_SHIP) + else + RELEASE_TREE = //blds-sca15a/components + endif + else + RELEASE_TREE = //blds-sca15a/components + endif + endif + ifeq ($(OS_TARGET), WIN16) + ifdef BUILD_SHIP + ifdef USE_SHIPS + RELEASE_TREE = $(NTBUILD_SHIP) + else + RELEASE_TREE = //blds-sca15a/components + endif + else + RELEASE_TREE = //blds-sca15a/components + endif + endif +endif + +# +# NOTE: export control policy enforced for XP and MD files +# released to the binary release tree +# + +ifeq ($(POLICY), domestic) + RELEASE_XP_DIR = domestic + RELEASE_MD_DIR = domestic/$(PLATFORM) +else + ifeq ($(POLICY), export) + RELEASE_XP_DIR = export + RELEASE_MD_DIR = export/$(PLATFORM) + else + ifeq ($(POLICY), france) + RELEASE_XP_DIR = france + RELEASE_MD_DIR = france/$(PLATFORM) + else + RELEASE_XP_DIR = + RELEASE_MD_DIR = $(PLATFORM) + endif + endif +endif + + +REPORTER_TREE = $(subst \,\\,$(RELEASE_TREE)) + +IMPORT_XP_DIR = +IMPORT_MD_DIR = $(PLATFORM) diff --git a/security/nss/lib/certdb/crl.c b/security/nss/lib/certdb/crl.c new file mode 100644 index 000000000..30a17a8fb --- /dev/null +++ b/security/nss/lib/certdb/crl.c @@ -0,0 +1,398 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +/* + * Moved from secpkcs7.c + * + * $Id$ + */ + +#include "cert.h" +#include "secder.h" +#include "secasn1.h" +#include "secoid.h" +#include "certdb.h" +#include "certxutl.h" +#include "prtime.h" +#include "secerr.h" + +const SEC_ASN1Template SEC_CERTExtensionTemplate[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(CERTCertExtension) }, + { SEC_ASN1_OBJECT_ID, + offsetof(CERTCertExtension,id) }, + { SEC_ASN1_OPTIONAL | SEC_ASN1_BOOLEAN, /* XXX DER_DEFAULT */ + offsetof(CERTCertExtension,critical), }, + { SEC_ASN1_OCTET_STRING, + offsetof(CERTCertExtension,value) }, + { 0, } +}; + +static const SEC_ASN1Template SEC_CERTExtensionsTemplate[] = { + { SEC_ASN1_SEQUENCE_OF, 0, SEC_CERTExtensionTemplate} +}; + +/* + * XXX Also, these templates, especially the Krl/FORTEZZA ones, need to + * be tested; Lisa did the obvious translation but they still should be + * verified. + */ + +const SEC_ASN1Template CERT_IssuerAndSNTemplate[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(CERTIssuerAndSN) }, + { SEC_ASN1_SAVE, + offsetof(CERTIssuerAndSN,derIssuer) }, + { SEC_ASN1_INLINE, + offsetof(CERTIssuerAndSN,issuer), + CERT_NameTemplate }, + { SEC_ASN1_INTEGER, + offsetof(CERTIssuerAndSN,serialNumber) }, + { 0 } +}; + +static const SEC_ASN1Template cert_KrlEntryTemplate[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(CERTCrlEntry) }, + { SEC_ASN1_OCTET_STRING, + offsetof(CERTCrlEntry,serialNumber) }, + { SEC_ASN1_UTC_TIME, + offsetof(CERTCrlEntry,revocationDate) }, + { 0 } +}; + +static const SEC_ASN1Template cert_KrlTemplate[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(CERTCrl) }, + { SEC_ASN1_INLINE, + offsetof(CERTCrl,signatureAlg), + SECOID_AlgorithmIDTemplate }, + { SEC_ASN1_SAVE, + offsetof(CERTCrl,derName) }, + { SEC_ASN1_INLINE, + offsetof(CERTCrl,name), + CERT_NameTemplate }, + { SEC_ASN1_UTC_TIME, + offsetof(CERTCrl,lastUpdate) }, + { SEC_ASN1_UTC_TIME, + offsetof(CERTCrl,nextUpdate) }, + { SEC_ASN1_OPTIONAL | SEC_ASN1_SEQUENCE_OF, + offsetof(CERTCrl,entries), + cert_KrlEntryTemplate }, + { 0 } +}; + +static const SEC_ASN1Template cert_SignedKrlTemplate[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(CERTSignedCrl) }, + { SEC_ASN1_SAVE, + offsetof(CERTSignedCrl,signatureWrap.data) }, + { SEC_ASN1_INLINE, + offsetof(CERTSignedCrl,crl), + cert_KrlTemplate }, + { SEC_ASN1_INLINE, + offsetof(CERTSignedCrl,signatureWrap.signatureAlgorithm), + SECOID_AlgorithmIDTemplate }, + { SEC_ASN1_BIT_STRING, + offsetof(CERTSignedCrl,signatureWrap.signature) }, + { 0 } +}; + +static const SEC_ASN1Template cert_CrlKeyTemplate[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(CERTCrlKey) }, + { SEC_ASN1_INTEGER | SEC_ASN1_OPTIONAL, offsetof(CERTCrlKey,dummy) }, + { SEC_ASN1_SKIP }, + { SEC_ASN1_ANY, offsetof(CERTCrlKey,derName) }, + { SEC_ASN1_SKIP_REST }, + { 0 } +}; + +static const SEC_ASN1Template cert_CrlEntryTemplate[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(CERTCrlEntry) }, + { SEC_ASN1_INTEGER, + offsetof(CERTCrlEntry,serialNumber) }, + { SEC_ASN1_UTC_TIME, + offsetof(CERTCrlEntry,revocationDate) }, + { SEC_ASN1_OPTIONAL | SEC_ASN1_SEQUENCE_OF, + offsetof(CERTCrlEntry, extensions), + SEC_CERTExtensionTemplate}, + { 0 } +}; + +const SEC_ASN1Template CERT_CrlTemplate[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(CERTCrl) }, + { SEC_ASN1_INTEGER | SEC_ASN1_OPTIONAL, offsetof (CERTCrl, version) }, + { SEC_ASN1_INLINE, + offsetof(CERTCrl,signatureAlg), + SECOID_AlgorithmIDTemplate }, + { SEC_ASN1_SAVE, + offsetof(CERTCrl,derName) }, + { SEC_ASN1_INLINE, + offsetof(CERTCrl,name), + CERT_NameTemplate }, + { SEC_ASN1_UTC_TIME, + offsetof(CERTCrl,lastUpdate) }, + { SEC_ASN1_OPTIONAL | SEC_ASN1_UTC_TIME, + offsetof(CERTCrl,nextUpdate) }, + { SEC_ASN1_OPTIONAL | SEC_ASN1_SEQUENCE_OF, + offsetof(CERTCrl,entries), + cert_CrlEntryTemplate }, + { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_CONTEXT_SPECIFIC | + SEC_ASN1_EXPLICIT | 0, + offsetof(CERTCrl,extensions), + SEC_CERTExtensionsTemplate}, + { 0 } +}; + +static const SEC_ASN1Template cert_SignedCrlTemplate[] = { + { SEC_ASN1_SEQUENCE, + 0, NULL, sizeof(CERTSignedCrl) }, + { SEC_ASN1_SAVE, + offsetof(CERTSignedCrl,signatureWrap.data) }, + { SEC_ASN1_INLINE, + offsetof(CERTSignedCrl,crl), + CERT_CrlTemplate }, + { SEC_ASN1_INLINE, + offsetof(CERTSignedCrl,signatureWrap.signatureAlgorithm), + SECOID_AlgorithmIDTemplate }, + { SEC_ASN1_BIT_STRING, + offsetof(CERTSignedCrl,signatureWrap.signature) }, + { 0 } +}; + +const SEC_ASN1Template CERT_SetOfSignedCrlTemplate[] = { + { SEC_ASN1_SET_OF, 0, cert_SignedCrlTemplate }, +}; + +/* Check the version of the CRL. If there is a critical extension in the crl + or crl entry, then the version must be v2. Otherwise, it should be v1. If + the crl contains critical extension(s), then we must recognized the extension's + OID. + */ +SECStatus cert_check_crl_version (CERTCrl *crl) +{ + CERTCrlEntry **entries; + CERTCrlEntry *entry; + PRBool hasCriticalExten = PR_FALSE; + SECStatus rv = SECSuccess; + int version; + + /* CRL version is defaulted to v1 */ + version = SEC_CRL_VERSION_1; + if (crl->version.data != 0) + version = (int)DER_GetUInteger (&crl->version); + + if (version > SEC_CRL_VERSION_2) { + PORT_SetError (SEC_ERROR_BAD_DER); + return (SECFailure); + } + + /* Check the crl extensions for a critial extension. If one is found, + and the version is not v2, then we are done. + */ + if (crl->extensions) { + hasCriticalExten = cert_HasCriticalExtension (crl->extensions); + if (hasCriticalExten) { + if (version != SEC_CRL_VERSION_2) + return (SECFailure); + /* make sure that there is no unknown critical extension */ + if (cert_HasUnknownCriticalExten (crl->extensions) == PR_TRUE) { + PORT_SetError (SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION); + return (SECFailure); + } + } + } + + + if (crl->entries == NULL) { + if (hasCriticalExten == PR_FALSE && version == SEC_CRL_VERSION_2) { + PORT_SetError (SEC_ERROR_BAD_DER); + return (SECFailure); + } + return (SECSuccess); + } + /* Look in the crl entry extensions. If there is a critical extension, + then the crl version must be v2; otherwise, it should be v1. + */ + entries = crl->entries; + while (*entries) { + entry = *entries; + if (entry->extensions) { + /* If there is a critical extension in the entries, then the + CRL must be of version 2. If we already saw a critical extension, + there is no need to check the version again. + */ + if (hasCriticalExten == PR_FALSE) { + hasCriticalExten = cert_HasCriticalExtension (entry->extensions); + if (hasCriticalExten && version != SEC_CRL_VERSION_2) { + rv = SECFailure; + break; + } + } + + /* For each entry, make sure that it does not contain an unknown + critical extension. If it does, we must reject the CRL since + we don't know how to process the extension. + */ + if (cert_HasUnknownCriticalExten (entry->extensions) == PR_TRUE) { + PORT_SetError (SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION); + rv = SECFailure; + break; + } + } + ++entries; + } + if (rv == SECFailure) + return (rv); + + /* There is no critical extension, but the version is set to v2 */ + if (version != SEC_CRL_VERSION_1 && hasCriticalExten == PR_FALSE) { + PORT_SetError (SEC_ERROR_BAD_DER); + return (SECFailure); + } + return (SECSuccess); +} + +/* + * Generate a database key, based on the issuer name from a + * DER crl. + */ +SECStatus +CERT_KeyFromDERCrl(PRArenaPool *arena, SECItem *derCrl, SECItem *key) +{ + SECStatus rv; + CERTSignedData sd; + CERTCrlKey crlkey; + + PORT_Memset (&sd, 0, sizeof (sd)); + rv = SEC_ASN1DecodeItem (arena, &sd, CERT_SignedDataTemplate, derCrl); + if (rv != SECSuccess) { + return rv; + } + + PORT_Memset (&crlkey, 0, sizeof (crlkey)); + rv = SEC_ASN1DecodeItem(arena, &crlkey, cert_CrlKeyTemplate, &sd.data); + if (rv != SECSuccess) { + return rv; + } + + key->len = crlkey.derName.len; + key->data = crlkey.derName.data; + + return(SECSuccess); +} + +/* + * take a DER CRL or KRL and decode it into a CRL structure + */ +CERTSignedCrl * +CERT_DecodeDERCrl(PRArenaPool *narena, SECItem *derSignedCrl, int type) +{ + PRArenaPool *arena; + CERTSignedCrl *crl; + SECStatus rv; + + /* make a new arena */ + if (narena == NULL) { + arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); + if ( !arena ) { + return NULL; + } + } else { + arena = narena; + } + + /* allocate the CRL structure */ + crl = (CERTSignedCrl *)PORT_ArenaZAlloc(arena, sizeof(CERTSignedCrl)); + if ( !crl ) { + goto loser; + } + + crl->arena = arena; + + /* Save the arena in the inner crl for CRL extensions support */ + crl->crl.arena = arena; + + /* decode the CRL info */ + switch (type) { + case SEC_CRL_TYPE: + rv = SEC_ASN1DecodeItem + (arena, crl, cert_SignedCrlTemplate, derSignedCrl); + if (rv != SECSuccess) + break; + +#ifdef notdef + /*this is a bogus check. all these fields are optional in a V2 cert.*/ + /* If the version is set to v2, make sure that it contains at + least 1 critical extension either the crl extensions or + crl entry extensions. */ + rv = cert_check_crl_version (&crl->crl); +#endif + break; + + case SEC_KRL_TYPE: + rv = SEC_ASN1DecodeItem + (arena, crl, cert_SignedKrlTemplate, derSignedCrl); + break; + default: + rv = SECFailure; + break; + } + + if (rv != SECSuccess) { + goto loser; + } + + crl->referenceCount = 1; + + return(crl); + +loser: + + if ((narena == NULL) && arena ) { + PORT_FreeArena(arena, PR_FALSE); + } + + return(0); +} + +/* These functions simply return the address of the above-declared templates. +** This is necessary for Windows DLLs. Sigh. +*/ +SEC_ASN1_CHOOSER_IMPLEMENT(CERT_IssuerAndSNTemplate) +SEC_ASN1_CHOOSER_IMPLEMENT(CERT_CrlTemplate) +SEC_ASN1_CHOOSER_IMPLEMENT(CERT_SetOfSignedCrlTemplate) + diff --git a/security/nss/lib/freebl/Makefile b/security/nss/lib/freebl/Makefile new file mode 100644 index 000000000..78cee89a0 --- /dev/null +++ b/security/nss/lib/freebl/Makefile @@ -0,0 +1,342 @@ +#! gmake +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +-include config.mk + +CPORLN = ln -s + +ifdef USE_64 + DEFINES += -DNSS_USE_64 +endif + +ifdef USE_HYBRID + DEFINES += -DNSS_USE_HYBRID +endif + +# des.c wants _X86_ defined for intel CPUs. +# coreconf does this for windows, but not for Linux, FreeBSD, etc. +ifeq ($(CPU_ARCH),x86) +ifneq ($(OS_ARCH),WINNT) + OS_REL_CFLAGS += -D_X86_ +endif +endif + +ifeq ($(OS_ARCH),WINNT) +CPORLN = cp +ifneq ($(OS_TARGET),WIN16) + ASFILES = mpi_x86.asm + DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE -DMP_ASSEMBLY_DIV_2DX1D +endif +endif + + +ifeq ($(OS_ARCH),IRIX) +ifeq ($(USE_N32),1) + ASFILES = mpi_mips.s + ASFLAGS = -O -OPT:Olimit=4000 -dollar -fullwarn -xansi -n32 -mips3 + DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE + DEFINES += -DMP_USE_UINT_DIGIT +else +endif +endif + +ifeq ($(OS_TARGET),Linux) +ifeq ($(CPU_ARCH),x86) + ASFILES = mpi_x86.s + DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE -DMP_ASSEMBLY_DIV_2DX1D +endif +endif + +ifeq ($(OS_ARCH),AIX) +DEFINES += -DMP_USE_UINT_DIGIT +ifndef USE_64 +DEFINES += -DMP_NO_DIV_WORD -DMP_NO_ADD_WORD -DMP_NO_SUB_WORD +endif +endif + +ifeq ($(OS_ARCH), HP-UX) +MKSHLIB += +k +vshlibunsats -u FREEBL_GetVector +e FREEBL_GetVector +ifndef FREEBL_EXTENDED_BUILD +ifdef USE_PURE_32 +# build for DA1.1 (HP PA 1.1) pure 32 bit model + DEFINES += -DMP_USE_UINT_DIGIT -DMP_NO_MP_WORD +else +ifdef USE_64 +# this builds for DA2.0W (HP PA 2.0 Wide), the LP64 ABI, using 32-bit digits + MPI_SRCS += mpi_hp.c + ASFILES += hpma512.s hppa20.s + DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE +else +# this builds for DA2.0 (HP PA 2.0 Narrow) hybrid model +# (the 32-bit ABI with 64-bit registers) using 32-bit digits + MPI_SRCS += mpi_hp.c + ASFILES += hpma512.s hppa20.s + DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE +# This is done in coreconf by defining USE_LONG_LONGS +# OS_CFLAGS += -Aa +e +DA2.0 +DS2.0 +endif +endif +endif +endif + +# Note: -xarch=v8 or v9 is now done in coreconf +ifeq ($(OS_TARGET),SunOS) +ifeq ($(CPU_ARCH),sparc) +ifndef NS_USE_GCC +ifndef USE_PURE_32 + OS_CFLAGS += -xchip=ultra2 +endif +endif +ifeq ($(OS_RELEASE),5.5.1) + SYSV_SPARC = 1 +endif +ifeq ($(OS_RELEASE),5.6) + SYSV_SPARC = 1 +endif +ifeq ($(OS_RELEASE),5.7) + SYSV_SPARC = 1 +endif +ifeq ($(OS_RELEASE),5.8) + SYSV_SPARC = 1 +endif +ifeq ($(SYSV_SPARC),1) +SOLARIS_AS = /usr/ccs/bin/as +ifdef NS_USE_GCC +LD = gcc +DSO_LDOPTS += -shared -Wl,-B,symbolic,-z,defs,-z,now,-z,text,-M,mapfile.Solaris +else +MKSHLIB += -B symbolic -z defs -z now -z text -M mapfile.Solaris +endif +ifdef USE_PURE_32 +# this builds for Sparc v8 pure 32-bit architecture + DEFINES += -DMP_USE_LONG_LONG_MULTIPLY -DMP_USE_UINT_DIGIT -DMP_NO_MP_WORD +else +ifdef USE_64 +# this builds for Sparc v9a pure 64-bit architecture + MPI_SRCS += mpi_sparc.c + ASFILES = mpv_sparcv9.s montmulfv9.s + DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_USING_MONT_MULF + DEFINES += -DMP_USE_UINT_DIGIT +# MPI_SRCS += mpv_sparc.c +# removed -xdepend from the following line + SOLARIS_FLAGS = -fast -xO5 -xrestrict=%all -xchip=ultra -xarch=v9a -KPIC -mt + SOLARIS_AS_FLAGS = -xarch=v9a -K PIC +else +# this builds for Sparc v8+a hybrid architecture, 64-bit registers, 32-bit ABI + MPI_SRCS += mpi_sparc.c + ASFILES = mpv_sparcv8.s montmulfv8.s + DEFINES += -DMP_NO_MP_WORD -DMP_ASSEMBLY_MULTIPLY -DMP_USING_MONT_MULF + DEFINES += -DMP_USE_UINT_DIGIT + SOLARIS_AS_FLAGS = -xarch=v8plusa -K PIC +# ASM_SUFFIX = .S +endif +endif +endif +else +# Solaris x86 + DEFINES += -DMP_USE_UINT_DIGIT + DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE -DMP_ASSEMBLY_DIV_2DX1D + ASFILES = mpi_i86pc.s +ifdef NS_USE_GCC + LD = gcc + AS = gcc + ASFLAGS = +endif + +endif +endif + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + +export:: private_export + +rijndael_tables: + $(CC) -o $(OBJDIR)/make_rijndael_tab rijndael_tables.c \ + $(DEFINES) $(INCLUDES) $(OBJDIR)/libfreebl.a + $(OBJDIR)/make_rijndael_tab + +ifdef MOZILLA_BSAFE_BUILD + +private_export:: +ifeq ($(OS_ARCH), WINNT) + rm -f $(DIST)/lib/bsafe$(BSAFEVER).lib +endif + $(NSINSTALL) -R $(BSAFEPATH) $(DIST)/lib +endif + +mp%.h : mpi/mp%.h + -$(CPORLN) $< . + +mp%.c : mpi/mp%.c + -$(CPORLN) $< . + +mp%.S : mpi/mp%.S + -$(CPORLN) $< . + +mp%.s : mpi/mp%.s + -$(CPORLN) $< . + +mp%.asm : mpi/mp%.asm + -$(CPORLN) $< . + +logtab.h : mpi/logtab.h + -$(CPORLN) $< . + +primes.c : mpi/primes.c + -$(CPORLN) $< . + +vis%.il : mpi/vis%.il + -$(CPORLN) $< . + +vis%.h : mpi/vis%.h + -$(CPORLN) $< . + +mont% : mpi/mont% + -$(CPORLN) $< . + +hp%.s : mpi/hp%.s + -$(CPORLN) $< . + +.PRECIOUS : $(MPI_SRCS) $(MPI_HDRS) $(ASFILES) + +ALL_TRASH += $(MPI_SRCS) $(MPI_HDRS) $(ASFILES) primes.c mont* + +DEFINES += -DMP_API_COMPATIBLE + +MPI_USERS = dh.c pqg.c dsa.c rsa.c + +MPI_OBJS = $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(MPI_SRCS:.c=$(OBJ_SUFFIX))) +MPI_OBJS += $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(MPI_USERS:.c=$(OBJ_SUFFIX))) + +$(MPI_OBJS): $(MPI_HDRS) primes.c + +ifeq ($(SYSV_SPARC),1) +SPARCFIX = $(OBJDIR)/sparcfix + +$(SPARCFIX): sparcfix.c + @$(MAKE_OBJDIR) + $(CC) -o $@ -O sparcfix.c -lelf + +#$(OBJDIR)/mpv_sparcv8.o $(OBJDIR)/montmulfv8.o : $(OBJDIR)/%.o : %.s $(SPARCFIX) +$(OBJDIR)/mpv_sparcv8.o $(OBJDIR)/montmulfv8.o : $(OBJDIR)/%.o : %.s + @$(MAKE_OBJDIR) + $(SOLARIS_AS) -o $@ $(SOLARIS_AS_FLAGS) $*.s +# $(SPARCFIX) $@ + +$(OBJDIR)/mpv_sparcv9.o $(OBJDIR)/montmulfv9.o : $(OBJDIR)/%.o : %.s + @$(MAKE_OBJDIR) + $(SOLARIS_AS) -o $@ $(SOLARIS_AS_FLAGS) $*.s + +$(OBJDIR)/mpv_sparc.o: vis_64.il vis_proto.h mpv_sparc.c + @$(MAKE_OBJDIR) + $(CC) -o $@ $(SOLARIS_FLAGS) -c vis_64.il mpv_sparc.c + +$(OBJDIR)/mpmontg.o: mpmontg.c montmulf.h +endif + +ifeq ($(OS_ARCH), HP-UX) +$(OBJDIR)/mpmontg.o: mpmontg.c montmulf.h +endif + +$(OBJDIR)/ldvector.o $(OBJDIR)/loader.o : loader.h + +ifdef FREEBL_EXTENDED_BUILD + +PURE32DIR = $(OS_ARCH)pure32 +ALL_TRASH += $(PURE32DIR) + +FILES2LN = \ + $(ALL_HDRS) \ + $(ALL_CSRCS) \ + $(wildcard *.tab) \ + $(wildcard mapfile.*) \ + Makefile manifest.mn config.mk + +LINKEDFILES = $(addprefix $(PURE32DIR)/, $(FILES2LN)) + +$(PURE32DIR): + -mkdir $(PURE32DIR) + -ln -s ../mpi $(PURE32DIR) + +$(LINKEDFILES) : $(PURE32DIR)/% : % + ln -s ../$* $(PURE32DIR) + +libs:: + $(MAKE) FREEBL_RECURSIVE_BUILD=1 USE_HYBRID=1 libs + +libs:: $(PURE32DIR) $(LINKEDFILES) + cd $(PURE32DIR) && $(MAKE) FREEBL_RECURSIVE_BUILD=1 USE_PURE_32=1 libs + +release_md:: + $(MAKE) FREEBL_RECURSIVE_BUILD=1 USE_HYBRID=1 $@ + cd $(PURE32DIR) && $(MAKE) FREEBL_RECURSIVE_BUILD=1 USE_PURE_32=1 $@ + +endif diff --git a/security/nss/lib/freebl/mpi/mpi_i86pc.s b/security/nss/lib/freebl/mpi/mpi_i86pc.s new file mode 100644 index 000000000..f6c167b1a --- /dev/null +++ b/security/nss/lib/freebl/mpi/mpi_i86pc.s @@ -0,0 +1,342 @@ + / + / The contents of this file are subject to the Mozilla Public + / License Version 1.1 (the "License"); you may not use this file + / except in compliance with the License. You may obtain a copy of + / the License at http://www.mozilla.org/MPL/ + / + / Software distributed under the License is distributed on an "AS + / IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + / implied. See the License for the specific language governing + / rights and limitations under the License. + / + / The Original Code is the Netscape security libraries. + / + / The Initial Developer of the Original Code is Netscape + / Communications Corporation. Portions created by Netscape are + / Copyright (C) 2001 Netscape Communications Corporation. All + / Rights Reserved. + / + / Contributor(s): + / + / Alternatively, the contents of this file may be used under the + / terms of the GNU General Public License Version 2 or later (the + / "GPL"), in which case the provisions of the GPL are applicable + / instead of those above. If you wish to allow use of your + / version of this file only under the terms of the GPL and not to + / allow others to use your version of this file under the MPL, + / indicate your decision by deleting the provisions above and + / replace them with the notice and other provisions required by + / the GPL. If you do not delete the provisions above, a recipient + / may use your version of this file under either the MPL or the + / GPL. + / $Id$ + / + +.text + + / ebp - 36: caller's esi + / ebp - 32: caller's edi + / ebp - 28: + / ebp - 24: + / ebp - 20: + / ebp - 16: + / ebp - 12: + / ebp - 8: + / ebp - 4: + / ebp + 0: caller's ebp + / ebp + 4: return address + / ebp + 8: a argument + / ebp + 12: a_len argument + / ebp + 16: b argument + / ebp + 20: c argument + / registers: + / eax: + / ebx: carry + / ecx: a_len + / edx: + / esi: a ptr + / edi: c ptr +.globl s_mpv_mul_d +.type s_mpv_mul_d,@function +s_mpv_mul_d: + push %ebp + mov %esp,%ebp + sub $28,%esp + push %edi + push %esi + push %ebx + movl $0,%ebx / carry = 0 + mov 12(%ebp),%ecx / ecx = a_len + mov 20(%ebp),%edi + cmp $0,%ecx + je L2 / jmp if a_len == 0 + mov 8(%ebp),%esi / esi = a + cld +L1: + lodsl / eax = [ds:esi]; esi += 4 + mov 16(%ebp),%edx / edx = b + mull %edx / edx:eax = Phi:Plo = a_i * b + + add %ebx,%eax / add carry (%ebx) to edx:eax + adc $0,%edx + mov %edx,%ebx / high half of product becomes next carry + + stosl / [es:edi] = ax; edi += 4; + dec %ecx / --a_len + jnz L1 / jmp if a_len != 0 +L2: + mov %ebx,0(%edi) / *c = carry + pop %ebx + pop %esi + pop %edi + leave + ret + nop + + / ebp - 36: caller's esi + / ebp - 32: caller's edi + / ebp - 28: + / ebp - 24: + / ebp - 20: + / ebp - 16: + / ebp - 12: + / ebp - 8: + / ebp - 4: + / ebp + 0: caller's ebp + / ebp + 4: return address + / ebp + 8: a argument + / ebp + 12: a_len argument + / ebp + 16: b argument + / ebp + 20: c argument + / registers: + / eax: + / ebx: carry + / ecx: a_len + / edx: + / esi: a ptr + / edi: c ptr +.globl s_mpv_mul_d_add +.type s_mpv_mul_d_add,@function +s_mpv_mul_d_add: + push %ebp + mov %esp,%ebp + sub $28,%esp + push %edi + push %esi + push %ebx + movl $0,%ebx / carry = 0 + mov 12(%ebp),%ecx / ecx = a_len + mov 20(%ebp),%edi + cmp $0,%ecx + je L4 / jmp if a_len == 0 + mov 8(%ebp),%esi / esi = a + cld +L3: + lodsl / eax = [ds:esi]; esi += 4 + mov 16(%ebp),%edx / edx = b + mull %edx / edx:eax = Phi:Plo = a_i * b + + add %ebx,%eax / add carry (%ebx) to edx:eax + adc $0,%edx + mov 0(%edi),%ebx / add in current word from *c + add %ebx,%eax + adc $0,%edx + mov %edx,%ebx / high half of product becomes next carry + + stosl / [es:edi] = ax; edi += 4; + dec %ecx / --a_len + jnz L3 / jmp if a_len != 0 +L4: + mov %ebx,0(%edi) / *c = carry + pop %ebx + pop %esi + pop %edi + leave + ret + nop + + / ebp - 36: caller's esi + / ebp - 32: caller's edi + / ebp - 28: + / ebp - 24: + / ebp - 20: + / ebp - 16: + / ebp - 12: + / ebp - 8: + / ebp - 4: + / ebp + 0: caller's ebp + / ebp + 4: return address + / ebp + 8: a argument + / ebp + 12: a_len argument + / ebp + 16: b argument + / ebp + 20: c argument + / registers: + / eax: + / ebx: carry + / ecx: a_len + / edx: + / esi: a ptr + / edi: c ptr +.globl s_mpv_mul_d_add_prop +.type s_mpv_mul_d_add_prop,@function +s_mpv_mul_d_add_prop: + push %ebp + mov %esp,%ebp + sub $28,%esp + push %edi + push %esi + push %ebx + movl $0,%ebx / carry = 0 + mov 12(%ebp),%ecx / ecx = a_len + mov 20(%ebp),%edi + cmp $0,%ecx + je L6 / jmp if a_len == 0 + cld + mov 8(%ebp),%esi / esi = a +L5: + lodsl / eax = [ds:esi]; esi += 4 + mov 16(%ebp),%edx / edx = b + mull %edx / edx:eax = Phi:Plo = a_i * b + + add %ebx,%eax / add carry (%ebx) to edx:eax + adc $0,%edx + mov 0(%edi),%ebx / add in current word from *c + add %ebx,%eax + adc $0,%edx + mov %edx,%ebx / high half of product becomes next carry + + stosl / [es:edi] = ax; edi += 4; + dec %ecx / --a_len + jnz L5 / jmp if a_len != 0 +L6: + cmp $0,%ebx / is carry zero? + jz L8 + mov 0(%edi),%eax / add in current word from *c + add %ebx,%eax + stosl / [es:edi] = ax; edi += 4; + jnc L8 +L7: + mov 0(%edi),%eax / add in current word from *c + adc $0,%eax + stosl / [es:edi] = ax; edi += 4; + jc L7 +L8: + pop %ebx + pop %esi + pop %edi + leave + ret + nop + + / ebp - 20: caller's esi + / ebp - 16: caller's edi + / ebp - 12: + / ebp - 8: carry + / ebp - 4: a_len local + / ebp + 0: caller's ebp + / ebp + 4: return address + / ebp + 8: pa argument + / ebp + 12: a_len argument + / ebp + 16: ps argument + / ebp + 20: + / registers: + / eax: + / ebx: carry + / ecx: a_len + / edx: + / esi: a ptr + / edi: c ptr + +.globl s_mpv_sqr_add_prop +.type s_mpv_sqr_add_prop,@function +s_mpv_sqr_add_prop: + push %ebp + mov %esp,%ebp + sub $12,%esp + push %edi + push %esi + push %ebx + movl $0,%ebx / carry = 0 + mov 12(%ebp),%ecx / a_len + mov 16(%ebp),%edi / edi = ps + cmp $0,%ecx + je L11 / jump if a_len == 0 + cld + mov 8(%ebp),%esi / esi = pa +L10: + lodsl / %eax = [ds:si]; si += 4; + mull %eax + + add %ebx,%eax / add "carry" + adc $0,%edx + mov 0(%edi),%ebx + add %ebx,%eax / add low word from result + mov 4(%edi),%ebx + stosl / [es:di] = %eax; di += 4; + adc %ebx,%edx / add high word from result + movl $0,%ebx + mov %edx,%eax + adc $0,%ebx + stosl / [es:di] = %eax; di += 4; + dec %ecx / --a_len + jnz L10 / jmp if a_len != 0 +L11: + cmp $0,%ebx / is carry zero? + jz L14 + mov 0(%edi),%eax / add in current word from *c + add %ebx,%eax + stosl / [es:edi] = ax; edi += 4; + jnc L14 +L12: + mov 0(%edi),%eax / add in current word from *c + adc $0,%eax + stosl / [es:edi] = ax; edi += 4; + jc L12 +L14: + pop %ebx + pop %esi + pop %edi + leave + ret + nop + + / + / Divide 64-bit (Nhi,Nlo) by 32-bit divisor, which must be normalized + / so its high bit is 1. This code is from NSPR. + / + / mp_err s_mpv_div_2dx1d(mp_digit Nhi, mp_digit Nlo, mp_digit divisor, + / mp_digit *qp, mp_digit *rp) + + / esp + 0: Caller's ebx + / esp + 4: return address + / esp + 8: Nhi argument + / esp + 12: Nlo argument + / esp + 16: divisor argument + / esp + 20: qp argument + / esp + 24: rp argument + / registers: + / eax: + / ebx: carry + / ecx: a_len + / edx: + / esi: a ptr + / edi: c ptr + / + +.globl s_mpv_div_2dx1d +.type s_mpv_div_2dx1d,@function +s_mpv_div_2dx1d: + push %ebx + mov 8(%esp),%edx + mov 12(%esp),%eax + mov 16(%esp),%ebx + div %ebx + mov 20(%esp),%ebx + mov %eax,0(%ebx) + mov 24(%esp),%ebx + mov %edx,0(%ebx) + xor %eax,%eax / return zero + pop %ebx + ret + nop + |