summaryrefslogtreecommitdiff
path: root/security/nss/lib/pkix/src/Name
diff options
context:
space:
mode:
authorrelyea%netscape.com <devnull@localhost>2000-03-31 19:14:40 +0000
committerrelyea%netscape.com <devnull@localhost>2000-03-31 19:14:40 +0000
commitdc6d4e64be376d12f325301e7e3c5cd048338e9a (patch)
tree4d7e4b2bfb30f304650fb9f179f0bf5778b04efc /security/nss/lib/pkix/src/Name
parent456170711c7d5b625326768a876245f52339d4f5 (diff)
downloadnss-hg-dc6d4e64be376d12f325301e7e3c5cd048338e9a.tar.gz
Initial NSS Open source checkin
Diffstat (limited to 'security/nss/lib/pkix/src/Name')
-rw-r--r--security/nss/lib/pkix/src/Name/Create.c93
-rw-r--r--security/nss/lib/pkix/src/Name/CreateFromRDNSequence.c79
-rw-r--r--security/nss/lib/pkix/src/Name/CreateFromUTF8.c81
-rw-r--r--security/nss/lib/pkix/src/Name/Decode.c79
-rw-r--r--security/nss/lib/pkix/src/Name/Destroy.c71
-rw-r--r--security/nss/lib/pkix/src/Name/Duplicate.c79
-rw-r--r--security/nss/lib/pkix/src/Name/Encode.c81
-rw-r--r--security/nss/lib/pkix/src/Name/Equal.c85
-rw-r--r--security/nss/lib/pkix/src/Name/GetChoice.c70
-rw-r--r--security/nss/lib/pkix/src/Name/GetRDNSequence.c80
-rw-r--r--security/nss/lib/pkix/src/Name/GetSpecifiedChoice.c90
-rw-r--r--security/nss/lib/pkix/src/Name/GetUTF8Encoding.c79
-rw-r--r--security/nss/lib/pkix/src/Name/MClear.c73
-rw-r--r--security/nss/lib/pkix/src/Name/Mregister.c72
-rw-r--r--security/nss/lib/pkix/src/Name/PCreate.c173
-rw-r--r--security/nss/lib/pkix/src/Name/PCreateFromRDNSequence.c145
-rw-r--r--security/nss/lib/pkix/src/Name/PCreateFromUTF8.c145
-rw-r--r--security/nss/lib/pkix/src/Name/PDecode.c138
-rw-r--r--security/nss/lib/pkix/src/Name/PDestroy.c76
-rw-r--r--security/nss/lib/pkix/src/Name/PDuplicate.c172
-rw-r--r--security/nss/lib/pkix/src/Name/PEncode.c118
-rw-r--r--security/nss/lib/pkix/src/Name/PEqual.c104
-rw-r--r--security/nss/lib/pkix/src/Name/PGetChoice.c68
-rw-r--r--security/nss/lib/pkix/src/Name/PGetRDNSequence.c87
-rw-r--r--security/nss/lib/pkix/src/Name/PGetSpecifiedChoice.c93
-rw-r--r--security/nss/lib/pkix/src/Name/PGetUTF8Encoding.c81
-rw-r--r--security/nss/lib/pkix/src/Name/template.c56
-rw-r--r--security/nss/lib/pkix/src/Name/verifyPointer.c210
28 files changed, 2778 insertions, 0 deletions
diff --git a/security/nss/lib/pkix/src/Name/Create.c b/security/nss/lib/pkix/src/Name/Create.c
new file mode 100644
index 000000000..dc9059f0b
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/Create.c
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_Create
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_INVALID_CHOICE
+ * NSS_ERROR_INVALID_ARGUMENT
+ *
+ * Return value:
+ * A valid pointer to an NSSPKIXName upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXName *
+NSSPKIXName_Create
+(
+ NSSArena *arenaOpt,
+ NSSPKIXNameChoice choice,
+ void *arg
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXName *)NULL;
+ }
+ }
+
+ switch( choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ {
+ NSSPKIXRDNSequence *r = (NSSPKIXRDNSequence *)arg;
+ if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(r) ) {
+ return (NSSPKIXName *)NULL;
+ }
+ }
+
+ break;
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ nss_SetError(NSS_ERROR_INVALID_CHOICE);
+ return (NSSPKIXName *)NULL;
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_Create(arenaOpt, choice, arg);
+}
diff --git a/security/nss/lib/pkix/src/Name/CreateFromRDNSequence.c b/security/nss/lib/pkix/src/Name/CreateFromRDNSequence.c
new file mode 100644
index 000000000..da07742cc
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/CreateFromRDNSequence.c
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_CreateFromRDNSequence
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE
+ *
+ * Return value:
+ * A valid pointer to an NSSPKIXName upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXName *
+NSSPKIXName_CreateFromRDNSequence
+(
+ NSSArena *arenaOpt,
+ NSSPKIXRDNSequence *rdnSequence
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXName *)NULL;
+ }
+ }
+
+ if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnSequence) ) {
+ return (NSSPKIXName *)NULL;
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_CreateFromRDNSequence(arenaOpt, rdnSequence);
+}
diff --git a/security/nss/lib/pkix/src/Name/CreateFromUTF8.c b/security/nss/lib/pkix/src/Name/CreateFromUTF8.c
new file mode 100644
index 000000000..f2111ea75
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/CreateFromUTF8.c
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_CreateFromUTF8
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_INVALID_STRING
+ * NSS_ERROR_UNKNOWN_ATTRIBUTE
+ *
+ * Return value:
+ * A valid pointer to an NSSPKIXName upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXName *
+NSSPKIXName_CreateFromUTF8
+(
+ NSSArena *arenaOpt,
+ NSSUTF8 *string
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXName *)NULL;
+ }
+ }
+
+ if( (NSSUTF8 *)NULL == string ) {
+ nss_SetError(NSS_ERROR_INVALID_STRING);
+ return (NSSPKIXRelativeDistinguishedName *)NULL;
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_CreateFromUTF8(arenaOpt, string);
+}
diff --git a/security/nss/lib/pkix/src/Name/Decode.c b/security/nss/lib/pkix/src/Name/Decode.c
new file mode 100644
index 000000000..b30fac01e
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/Decode.c
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_CreateFromBER
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_BER
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_INVALID_ARENA
+ *
+ * Return value:
+ * A valid pointer to an NSSPKIXName upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXName *
+NSSPKIXName_CreateFromBER
+(
+ NSSArena *arenaOpt,
+ NSSBER *ber
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXName *)NULL;
+ }
+ }
+
+ if( PR_SUCCESS != nssItem_verifyPointer(ber) ) {
+ return (NSSPKIXName *)NULL;
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_CreateFromBER(arenaOpt, ber);
+}
diff --git a/security/nss/lib/pkix/src/Name/Destroy.c b/security/nss/lib/pkix/src/Name/Destroy.c
new file mode 100644
index 000000000..c8c2bc9f2
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/Destroy.c
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_Destroy
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ *
+ * Return value:
+ * PR_SUCCESS upon success
+ * PR_FAILURE upon failure
+ */
+
+NSS_IMPLEMENT PRStatus
+NSSPKIXName_Destroy
+(
+ NSSPKIXName *name
+)
+{
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return PR_FAILURE;
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_Destroy(name);
+}
diff --git a/security/nss/lib/pkix/src/Name/Duplicate.c b/security/nss/lib/pkix/src/Name/Duplicate.c
new file mode 100644
index 000000000..6c8831729
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/Duplicate.c
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_Duplicate
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_NO_MEMORY
+ *
+ * Return value:
+ * A valid pointer to an NSSPKIXName upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXName *
+NSSPKIXName_Duplicate
+(
+ NSSPKIXName *name,
+ NSSArena *arenaOpt
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return (NSSDER *)NULL;
+ }
+
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSDER *)NULL;
+ }
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_Duplicate(name, arenaOpt);
+}
diff --git a/security/nss/lib/pkix/src/Name/Encode.c b/security/nss/lib/pkix/src/Name/Encode.c
new file mode 100644
index 000000000..344a53724
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/Encode.c
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_Encode
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_NO_MEMORY
+ *
+ * Return value:
+ * A valid NSSBER pointer upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSBER *
+NSSPKIXName_Encode
+(
+ NSSPKIXName *name,
+ NSSASN1EncodingType encoding,
+ NSSBER *rvOpt,
+ NSSArena *arenaOpt
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return (NSSBER *)NULL;
+ }
+
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSBER *)NULL;
+ }
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_Encode(name, rvOpt, arenaOpt);
+}
diff --git a/security/nss/lib/pkix/src/Name/Equal.c b/security/nss/lib/pkix/src/Name/Equal.c
new file mode 100644
index 000000000..9a74eef94
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/Equal.c
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_Equal
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ *
+ * Return value:
+ * PR_TRUE if the two objects have equal values
+ * PR_FALSE otherwise
+ * PR_FALSE upon error
+ */
+
+NSS_IMPLEMENT PRBool
+NSSPKIXName_Equal
+(
+ NSSPKIXName *name1,
+ NSSPKIXName *name2,
+ PRStatus *statusOpt
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(name1) ) {
+ if( (PRStatus *)NULL != statusOpt ) {
+ *statusOpt = PR_FAILURE;
+ }
+
+ return PR_FALSE;
+ }
+
+ if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(name2) ) {
+ if( (PRStatus *)NULL != statusOpt ) {
+ *statusOpt = PR_FAILURE;
+ }
+
+ return PR_FALSE;
+ }
+#endif /* DEBUG */
+
+ return nssPKIX_Equal(name1, name2, statusOpt);
+}
diff --git a/security/nss/lib/pkix/src/Name/GetChoice.c b/security/nss/lib/pkix/src/Name/GetChoice.c
new file mode 100644
index 000000000..8a36ada00
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/GetChoice.c
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_GetChoice
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ *
+ * Return value:
+ * A valid element of the NSSPKIXNameChoice enumeration upon success
+ * The value NSSPKIXNameChoice_NSSinvalid (-1) upon error
+ */
+
+NSS_IMPLEMENT NSSPKIXNameChoice
+NSSPKIXName_GetChoice
+(
+ NSSPKIXName *name
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return NSSPKIXNameChoice_NSSinvalid;
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_GetChoice(name);
+}
diff --git a/security/nss/lib/pkix/src/Name/GetRDNSequence.c b/security/nss/lib/pkix/src/Name/GetRDNSequence.c
new file mode 100644
index 000000000..94562ae3c
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/GetRDNSequence.c
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_GetRDNSequence
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_WRONG_CHOICE
+ *
+ * Return value:
+ * A pointer to a valid NSSPKIXRDNSequence upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXRDNSequence *
+NSSPKIXName_GetRDNSequence
+(
+ NSSPKIXName *name,
+ NSSArena *arenaOpt
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) {
+ return (NSSPKIXRDNSequence *)NULL;
+ }
+
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXRDNSequence *)NULL;
+ }
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_GetRDNSequence(name, arenaOpt);
+}
diff --git a/security/nss/lib/pkix/src/Name/GetSpecifiedChoice.c b/security/nss/lib/pkix/src/Name/GetSpecifiedChoice.c
new file mode 100644
index 000000000..3de2d5b84
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/GetSpecifiedChoice.c
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_GetSpecifiedChoice
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_WRONG_CHOICE
+ *
+ * Return value:
+ * A valid pointer ...
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT void *
+NSSPKIXName_GetSpecifiedChoice
+(
+ NSSPKIXName *name,
+ NSSPKIXNameChoice choice,
+ NSSArena *arenaOpt
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(name) ) {
+ return (void *)NULL;
+ }
+
+ switch( choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ break;
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ nss_SetError(NSS_ERROR_INVALID_CHOICE);
+ return (void *)NULL;
+ }
+
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (void *)NULL;
+ }
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_GetSpecifiedChoice(name, choice, arenaOpt);
+}
diff --git a/security/nss/lib/pkix/src/Name/GetUTF8Encoding.c b/security/nss/lib/pkix/src/Name/GetUTF8Encoding.c
new file mode 100644
index 000000000..c86dd94b2
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/GetUTF8Encoding.c
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * NSSPKIXName_GetUTF8Encoding
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_NO_MEMORY
+ *
+ * Return value:
+ * A valid NSSUTF8 pointer upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSUTF8 *
+NSSPKIXName_GetUTF8Encoding
+(
+ NSSPKIXName *name,
+ NSSArena *arenaOpt
+)
+{
+ nss_ClearErrorStack();
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return (NSSUTF8 *)NULL;
+ }
+
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSUTF8 *)NULL;
+ }
+ }
+#endif /* DEBUG */
+
+ return nssPKIXName_GetUTF8Encoding(name, arenaOpt);
+}
diff --git a/security/nss/lib/pkix/src/Name/MClear.c b/security/nss/lib/pkix/src/Name/MClear.c
new file mode 100644
index 000000000..e8d6b1961
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/MClear.c
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nss_pkix_Name_Clear
+ *
+ * Wipes out cached data.
+ */
+
+NSS_IMPLEMENT PRStatus
+nss_pkix_Name_Clear
+(
+ NSSPKIXName *name
+)
+{
+#ifdef NSSDEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return PR_FAILURE;
+ }
+#endif /* NSSDEBUG */
+
+ if( (NSSBER *)NULL != name->ber ) {
+ nss_ZFreeIf(name->ber->data);
+ nss_ZFreeIf(name->ber);
+ }
+
+ if( (NSSDER *)NULL != name->der ) {
+ nss_ZFreeIf(name->der->data);
+ nss_ZFreeIf(name->der);
+ }
+
+ nss_ZFreeIf(name->utf8);
+
+ return PR_SUCCESS;
+}
diff --git a/security/nss/lib/pkix/src/Name/Mregister.c b/security/nss/lib/pkix/src/Name/Mregister.c
new file mode 100644
index 000000000..09ddb9d99
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/Mregister.c
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+#ifdef NSSDEBUG
+/*
+ * nss_pkix_Name_register
+ *
+ * Registers whatever sub-component exists within this Name.
+ */
+
+NSS_IMPLEMENT PRStatus
+nss_pkix_Name_register
+(
+ NSSPKIXName *name
+)
+{
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return PR_FAILURE;
+ }
+
+ switch( name->choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ /* add pointer */
+ /* (sub-)register pointer */
+ /* add destructor to arena */
+ break;
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ nss_SetError(NSS_ERROR_INTERNAL_ERROR);
+ return PR_FAILURE;
+ }
+
+ return PR_SUCCESS;
+}
diff --git a/security/nss/lib/pkix/src/Name/PCreate.c b/security/nss/lib/pkix/src/Name/PCreate.c
new file mode 100644
index 000000000..e93737599
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PCreate.c
@@ -0,0 +1,173 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_Create
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_INVALID_CHOICE
+ * NSS_ERROR_INVALID_ARGUMENT
+ *
+ * Return value:
+ * A valid pointer to an NSSPKIXName upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXName *
+nssPKIXName_Create
+(
+ NSSArena *arenaOpt,
+ NSSPKIXNameChoice choice,
+ void *arg
+)
+{
+ NSSArena *arena;
+ PRBool arena_allocated = PR_FALSE;
+ nssArenaMark *mark = (nssArenaMark *)NULL;
+ NSSPKIXName *rv = (NSSPKIXName *)NULL;
+ PRStatus status;
+ PRUint32 i;
+
+#ifdef NSSDEBUG
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXName *)NULL;
+ }
+ }
+
+ switch( choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ if( (PR_SUCCESS != nssPKIXRDNSequence_verifyPointer((NSSPKIXRDNSequence *)arg) ) ) {
+ nss_SetError(NSS_ERROR_INVALID_ARGUMENT);
+ return (NSSPKIXName *)NULL;
+ }
+ break;
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ nss_SetError(NSS_ERROR_INVALID_CHOICE);
+ return (NSSPKIXName *)NULL;
+ }
+#endif /* NSSDEBUG */
+
+ switch( choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ break;
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ nss_SetError(NSS_ERROR_INVALID_CHOICE);
+ goto loser;
+ }
+
+ if( (NSSArena *)NULL == arenaOpt ) {
+ arena = nssArena_Create();
+ if( (NSSArena *)NULL == arena ) {
+ goto loser;
+ }
+ arena_allocated = PR_TRUE;
+ } else {
+ arena = arenaOpt;
+ mark = nssArena_Mark(arena);
+ if( (nssArenaMark *)NULL == mark ) {
+ goto loser;
+ }
+ }
+
+ rv = nss_ZNEW(arena, NSSPKIXName);
+ if( (NSSPKIXName *)NULL == rv ) {
+ goto loser;
+ }
+
+ rv->arena = arena;
+ rv->i_allocated_arena = arena_allocated;
+ rv->utf8 = nssUTF8_Duplicate(string, arena);
+ if( (NSSUTF8 *)NULL == rv->utf8 ) {
+ goto loser;
+ }
+
+ rv->choice = choice;
+ switch( choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ rv->u.rdnSequence = nssPKIXRDNSequence_Duplicate((NSSPKIXRDNSequence *)arg, arena);
+ if( (NSSPKIXRDNSequence *)NULL == rv->u.rdnSequence ) {
+ goto loser;
+ }
+ break;
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ nss_SetError(NSS_ERROR_INVALID_CHOICE);
+ goto loser;
+ }
+
+ if( (nssArenaMark *)NULL != mark ) {
+ if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) {
+ goto loser;
+ }
+ }
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nss_pkix_Name_add_pointer(rv) ) {
+ goto loser;
+ }
+
+ if( PR_SUCCESS != nssArena_registerDestructor(arena,
+ nss_pkix_Name_remove_pointer, rv) ) {
+ (void)nss_pkix_Name_remove_pointer(rv);
+ goto loser;
+ }
+#endif /* DEBUG */
+
+ return rv;
+
+ loser:
+ if( (nssArenaMark *)NULL != mark ) {
+ (void)nssArena_Release(arena, mark);
+ }
+
+ if( PR_TRUE == arena_allocated ) {
+ (void)nssArena_Destroy(arena);
+ }
+
+ return (NSSPKIXName *)NULL;
+}
diff --git a/security/nss/lib/pkix/src/Name/PCreateFromRDNSequence.c b/security/nss/lib/pkix/src/Name/PCreateFromRDNSequence.c
new file mode 100644
index 000000000..169e409a3
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PCreateFromRDNSequence.c
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_CreateFromRDNSequence
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE
+ *
+ * Return value:
+ * A valid pointer to an NSSPKIXName upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXName *
+nssPKIXName_CreateFromRDNSequence
+(
+ NSSArena *arenaOpt,
+ NSSPKIXRDNSequence *rdnSequence
+)
+{
+ NSSArena *arena;
+ PRBool arena_allocated = PR_FALSE;
+ nssArenaMark *mark = (nssArenaMark *)NULL;
+ NSSPKIXName *rv = (NSSPKIXName *)NULL;
+ PRStatus status;
+ PRUint32 i;
+
+#ifdef NSSDEBUG
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXName *)NULL;
+ }
+ }
+
+ if( (PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnSequence) ) ) {
+ return (NSSPKIXName *)NULL;
+ }
+#endif /* NSSDEBUG */
+
+ if( (NSSArena *)NULL == arenaOpt ) {
+ arena = nssArena_Create();
+ if( (NSSArena *)NULL == arena ) {
+ goto loser;
+ }
+ arena_allocated = PR_TRUE;
+ } else {
+ arena = arenaOpt;
+ mark = nssArena_Mark(arena);
+ if( (nssArenaMark *)NULL == mark ) {
+ goto loser;
+ }
+ }
+
+ rv = nss_ZNEW(arena, NSSPKIXName);
+ if( (NSSPKIXName *)NULL == rv ) {
+ goto loser;
+ }
+
+ rv->arena = arena;
+ rv->i_allocated_arena = arena_allocated;
+ rv->utf8 = nssUTF8_Duplicate(string, arena);
+ if( (NSSUTF8 *)NULL == rv->utf8 ) {
+ goto loser;
+ }
+
+ rv->choice = NSSPKIXNameChoice_rdnSequence;
+ rv->u.rdnSequence = nssPKIXRDNSequence_Duplicate(rdnSequence, arena);
+ if( (NSSPKIXRDNSequence *)NULL == rv->u.rdnSequence ) {
+ goto loser;
+ }
+
+ if( (nssArenaMark *)NULL != mark ) {
+ if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) {
+ goto loser;
+ }
+ }
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nss_pkix_Name_add_pointer(rv) ) {
+ goto loser;
+ }
+
+ if( PR_SUCCESS != nssArena_registerDestructor(arena,
+ nss_pkix_Name_remove_pointer, rv) ) {
+ (void)nss_pkix_Name_remove_pointer(rv);
+ goto loser;
+ }
+#endif /* DEBUG */
+
+ return rv;
+
+ loser:
+ if( (nssArenaMark *)NULL != mark ) {
+ (void)nssArena_Release(arena, mark);
+ }
+
+ if( PR_TRUE == arena_allocated ) {
+ (void)nssArena_Destroy(arena);
+ }
+
+ return (NSSPKIXName *)NULL;
+}
diff --git a/security/nss/lib/pkix/src/Name/PCreateFromUTF8.c b/security/nss/lib/pkix/src/Name/PCreateFromUTF8.c
new file mode 100644
index 000000000..0939a19e3
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PCreateFromUTF8.c
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_CreateFromUTF8
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_INVALID_STRING
+ * NSS_ERROR_UNKNOWN_ATTRIBUTE
+ *
+ * Return value:
+ * A valid pointer to an NSSPKIXName upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXName *
+nssPKIXName_CreateFromUTF8
+(
+ NSSArena *arenaOpt,
+ NSSUTF8 *string
+)
+{
+ NSSArena *arena;
+ PRBool arena_allocated = PR_FALSE;
+ nssArenaMark *mark = (nssArenaMark *)NULL;
+ NSSPKIXName *rv = (NSSPKIXName *)NULL;
+ PRStatus status;
+ PRUint32 i;
+
+#ifdef NSSDEBUG
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXName *)NULL;
+ }
+ }
+
+ if( (NSSUTF8 *)NULL == string ) {
+ nss_SetError(NSS_ERROR_INVALID_STRING);
+ return (NSSPKIXName *)NULL;
+ }
+#endif /* NSSDEBUG */
+
+ if( (NSSArena *)NULL == arenaOpt ) {
+ arena = nssArena_Create();
+ if( (NSSArena *)NULL == arena ) {
+ goto loser;
+ }
+ arena_allocated = PR_TRUE;
+ } else {
+ arena = arenaOpt;
+ mark = nssArena_Mark(arena);
+ if( (nssArenaMark *)NULL == mark ) {
+ goto loser;
+ }
+ }
+
+ rv = nss_ZNEW(arena, NSSPKIXName);
+ if( (NSSPKIXName *)NULL == rv ) {
+ goto loser;
+ }
+
+ rv->arena = arena;
+ rv->i_allocated_arena = arena_allocated;
+ rv->utf8 = nssUTF8_Duplicate(string, arena);
+ if( (NSSUTF8 *)NULL == rv->utf8 ) {
+ goto loser;
+ }
+
+ /* Insert intelligence here -- fgmr */
+ nss_SetError(NSS_ERROR_INTERNAL_ERROR);
+ goto loser;
+
+ if( (nssArenaMark *)NULL != mark ) {
+ if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) {
+ goto loser;
+ }
+ }
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nss_pkix_Name_add_pointer(rv) ) {
+ goto loser;
+ }
+
+ if( PR_SUCCESS != nssArena_registerDestructor(arena,
+ nss_pkix_Name_remove_pointer, rv) ) {
+ (void)nss_pkix_Name_remove_pointer(rv);
+ goto loser;
+ }
+#endif /* DEBUG */
+
+ return rv;
+
+ loser:
+ if( (nssArenaMark *)NULL != mark ) {
+ (void)nssArena_Release(arena, mark);
+ }
+
+ if( PR_TRUE == arena_allocated ) {
+ (void)nssArena_Destroy(arena);
+ }
+
+ return (NSSPKIXName *)NULL;
+}
diff --git a/security/nss/lib/pkix/src/Name/PDecode.c b/security/nss/lib/pkix/src/Name/PDecode.c
new file mode 100644
index 000000000..d3f20d473
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PDecode.c
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_CreateFromBER
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_BER
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_INVALID_ARENA
+ *
+ * Return value:
+ * A valid pointer to an NSSPKIXName upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXName *
+nssPKIXName_CreateFromBER
+(
+ NSSArena *arenaOpt,
+ NSSBER *ber
+)
+{
+ NSSArena *arena;
+ PRBool arena_allocated = PR_FALSE;
+ nssArenaMark *mark = (nssArenaMark *)NULL;
+ NSSPKIXName *rv = (NSSPKIXName *)NULL;
+ PRStatus status;
+ PRUint32 i;
+
+#ifdef NSSDEBUG
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXName *)NULL;
+ }
+ }
+
+ if( PR_SUCCESS != nssItem_verifyPointer(ber) ) {
+ return (NSSPKIXName *)NULL;
+ }
+#endif /* NSSDEBUG */
+
+ if( (NSSArena *)NULL == arenaOpt ) {
+ arena = nssArena_Create();
+ if( (NSSArena *)NULL == arena ) {
+ goto loser;
+ }
+ arena_allocated = PR_TRUE;
+ } else {
+ arena = arenaOpt;
+ mark = nssArena_Mark(arena);
+ if( (nssArenaMark *)NULL == mark ) {
+ goto loser;
+ }
+ }
+
+ rv = nss_ZNEW(arena, NSSPKIXName);
+ if( (NSSPKIXName *)NULL == rv ) {
+ goto loser;
+ }
+
+ rv->arena = arena;
+ rv->i_allocated_arena = arena_allocated;
+ rv->ber = nssItem_Duplicate(ber, arena, (NSSItem *)NULL);
+ if( (NSSItem *)NULL == rv->ber ) {
+ goto loser;
+ }
+
+ status = nssASN1_DecodeBER(arena, rv, nssPKIXName_template, ber);
+ if( PR_SUCCESS != status ) {
+ goto loser;
+ }
+
+ if( (nssArenaMark *)NULL != mark ) {
+ if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) {
+ goto loser;
+ }
+ }
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nss_pkix_Name_add_pointer(rv) ) {
+ goto loser;
+ }
+#endif /* DEBUG */
+
+ return rv;
+
+ loser:
+ if( (nssArenaMark *)NULL != mark ) {
+ (void)nssArena_Release(arena, mark);
+ }
+
+ if( PR_TRUE == arena_allocated ) {
+ (void)nssArena_Destroy(arena);
+ }
+
+ return (NSSPKIXName *)NULL;
+}
diff --git a/security/nss/lib/pkix/src/Name/PDestroy.c b/security/nss/lib/pkix/src/Name/PDestroy.c
new file mode 100644
index 000000000..f1fd41721
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PDestroy.c
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_Destroy
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ *
+ * Return value:
+ * PR_SUCCESS upon success
+ * PR_FAILURE upon failure
+ */
+
+NSS_IMPLEMENT PRStatus
+nssPKIXName_Destroy
+(
+ NSSPKIXName *name
+)
+{
+#ifdef NSSDEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return PR_FAILURE;
+ }
+#endif /* NSSDEBUG */
+
+#ifdef DEBUG
+ (void)nss_pkix_Name_remove_pointer(name);
+#endif /* DEBUG */
+
+ if( PR_TRUE == name->i_allocated_arena ) {
+ return nssArena_Destroy(name->arena);
+ }
+
+ return PR_SUCCESS;
+}
diff --git a/security/nss/lib/pkix/src/Name/PDuplicate.c b/security/nss/lib/pkix/src/Name/PDuplicate.c
new file mode 100644
index 000000000..c5788a0f1
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PDuplicate.c
@@ -0,0 +1,172 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_Duplicate
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_NO_MEMORY
+ *
+ * Return value:
+ * A valid pointer to an NSSPKIXName upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXName *
+nssPKIXName_Duplicate
+(
+ NSSPKIXName *name,
+ NSSArena *arenaOpt
+)
+{
+ NSSArena *arena;
+ PRBool arena_allocated = PR_FALSE;
+ nssArenaMark *mark = (nssArenaMark *)NULL;
+ NSSPKIXName *rv = (NSSPKIXName *)NULL;
+ PRStatus status;
+ PRUint32 i;
+
+#ifdef NSSDEBUG
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXName *)NULL;
+ }
+ }
+
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSUTF8 *)NULL;
+ }
+ }
+#endif /* NSSDEBUG */
+
+ if( (NSSArena *)NULL == arenaOpt ) {
+ arena = nssArena_Create();
+ if( (NSSArena *)NULL == arena ) {
+ goto loser;
+ }
+ arena_allocated = PR_TRUE;
+ } else {
+ arena = arenaOpt;
+ mark = nssArena_Mark(arena);
+ if( (nssArenaMark *)NULL == mark ) {
+ goto loser;
+ }
+ }
+
+ rv = nss_ZNEW(arena, NSSPKIXName);
+ if( (NSSPKIXName *)NULL == rv ) {
+ goto loser;
+ }
+
+ rv->arena = arena;
+ rv->i_allocated_arena = arena_allocated;
+
+ if( (NSSBER *)NULL != name->ber ) {
+ rv->ber = nssItem_Duplicate(name->ber, arena, (NSSItem *)NULL);
+ if( (NSSBER *)NULL == rv->ber ) {
+ goto loser;
+ }
+ }
+
+ if( (NSSDER *)NULL != name->der ) {
+ rv->der = nssItem_Duplicate(name->der, arena, (NSSItem *)NULL);
+ if( (NSSDER *)NULL == rv->der ) {
+ goto loser;
+ }
+ }
+
+ if( (NSSUTF8 *)NULL != name->utf8 ) {
+ rv->utf8 = nssUTF8_duplicate(name->utf8, arena);
+ if( (NSSUTF8 *)NULL == rv->utf8 ) {
+ goto loser;
+ }
+ }
+
+ rv->choice = name->choice;
+ switch( name->choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ rv->u.rdnSequence = nssPKIXRDNSequence_Duplicate(name->u.rdnSequence, arena);
+ if( (NSSPKIXRDNSequence *)NULL == rv->u.rdnSequence ) {
+ goto loser;
+ }
+ break;
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ nss_SetError(NSS_ERROR_INTERNAL_ERROR);
+ goto loser;
+ }
+
+ if( (nssArenaMark *)NULL != mark ) {
+ if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) {
+ goto loser;
+ }
+ }
+
+#ifdef DEBUG
+ if( PR_SUCCESS != nss_pkix_Name_add_pointer(rv) ) {
+ goto loser;
+ }
+
+ if( PR_SUCCESS != nssArena_registerDestructor(arena,
+ nss_pkix_Name_remove_pointer, rv) ) {
+ (void)nss_pkix_Name_remove_pointer(rv);
+ goto loser;
+ }
+#endif /* DEBUG */
+
+ return rv;
+
+ loser:
+ if( (nssArenaMark *)NULL != mark ) {
+ (void)nssArena_Release(arena, mark);
+ }
+
+ if( PR_TRUE == arena_allocated ) {
+ (void)nssArena_Destroy(arena);
+ }
+
+ return (NSSPKIXName *)NULL;
+}
diff --git a/security/nss/lib/pkix/src/Name/PEncode.c b/security/nss/lib/pkix/src/Name/PEncode.c
new file mode 100644
index 000000000..469b528fb
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PEncode.c
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_Encode
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_NO_MEMORY
+ *
+ * Return value:
+ * A valid NSSBER pointer upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSBER *
+nssPKIXName_Encode
+(
+ NSSPKIXName *name,
+ NSSASN1EncodingType encoding,
+ NSSBER *rvOpt,
+ NSSArena *arenaOpt
+)
+{
+ NSSBER *it;
+
+#ifdef NSSDEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return (NSSBER *)NULL;
+ }
+
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSBER *)NULL;
+ }
+ }
+#endif /* NSSDEBUG */
+
+ switch( encoding ) {
+ case NSSASN1BER:
+ if( (NSSBER *)NULL != name->ber ) {
+ it = name->ber;
+ goto done;
+ }
+ /*FALLTHROUGH*/
+ case NSSASN1DER:
+ if( (NSSDER *)NULL != name->der ) {
+ it = name->der;
+ goto done;
+ }
+ break;
+ default:
+ nss_SetError(NSS_ERROR_UNSUPPORTED_ENCODING);
+ return (NSSBER *)NULL;
+ }
+
+ it = nssASN1_EncodeItem(name->arena, (NSSItem *)NULL, name,
+ nssPKIXName_template, encoding);
+ if( (NSSBER *)NULL == it ) {
+ return (NSSBER *)NULL;
+ }
+
+ switch( encoding ) {
+ case NSSASN1BER:
+ name->ber = it;
+ break;
+ case NSSASN1DER:
+ name->der = it;
+ break;
+ default:
+ PR_ASSERT(0);
+ break;
+ }
+
+ done:
+ return nssItem_Duplicate(it, arenaOpt, rvOpt);
+}
diff --git a/security/nss/lib/pkix/src/Name/PEqual.c b/security/nss/lib/pkix/src/Name/PEqual.c
new file mode 100644
index 000000000..5ad91dd2a
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PEqual.c
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_Equal
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ *
+ * Return value:
+ * PR_TRUE if the two objects have equal values
+ * PR_FALSE otherwise
+ * PR_FALSE upon error
+ */
+
+NSS_IMPLEMENT PRBool
+nssPKIXName_Equal
+(
+ NSSPKIXName *one,
+ NSSPKIXName *two,
+ PRStatus *statusOpt
+)
+{
+#ifdef NSSDEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(one) ) {
+ if( (PRStatus *)NULL != statusOpt ) {
+ *statusOpt = PR_FAILURE;
+ }
+ return PR_FALSE;
+ }
+
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(two) ) {
+ if( (PRStatus *)NULL != statusOpt ) {
+ *statusOpt = PR_FAILURE;
+ }
+ return PR_FALSE;
+ }
+#endif /* NSSDEBUG */
+
+ if( ((NSSDER *)NULL != one->der) && ((NSSDER *)NULL != two->der) ) {
+ return nssItem_Equal(one->der, two->der, statusOpt);
+ }
+
+ if( one->choice != two->choice ) {
+ if( (PRStatus *)NULL != statusOpt ) {
+ *statusOpt = PR_SUCCESS;
+ }
+ return PR_FALSE;
+ }
+
+ switch( one->choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ return nssPKIXRDNSequence_Equal(one->u.rdnSequence, two->u.rdnSequence, statusOpt);
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ break;
+ }
+
+ nss_SetError(NSS_ERROR_INTERNAL_ERROR);
+ if( (PRStatus *)NULL != statusOpt ) {
+ *statusOpt = PR_FAILURE;
+ }
+ return PR_FALSE;
+}
diff --git a/security/nss/lib/pkix/src/Name/PGetChoice.c b/security/nss/lib/pkix/src/Name/PGetChoice.c
new file mode 100644
index 000000000..f34a93908
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PGetChoice.c
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_GetChoice
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ *
+ * Return value:
+ * A valid element of the NSSPKIXNameChoice enumeration upon success
+ * The value NSSPKIXNameChoice_NSSinvalid (-1) upon error
+ */
+
+NSS_IMPLEMENT NSSPKIXNameChoice
+nssPKIXName_GetChoice
+(
+ NSSPKIXName *name
+)
+{
+#ifdef NSSDEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return NSSPKIXNameChoice_NSSinvalid;
+ }
+#endif /* NSSDEBUG */
+
+ return name->choice;
+}
diff --git a/security/nss/lib/pkix/src/Name/PGetRDNSequence.c b/security/nss/lib/pkix/src/Name/PGetRDNSequence.c
new file mode 100644
index 000000000..0899e550d
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PGetRDNSequence.c
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_GetRDNSequence
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_WRONG_CHOICE
+ *
+ * Return value:
+ * A pointer to a valid NSSPKIXRDNSequence upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSPKIXRDNSequence *
+nssPKIXName_GetRDNSequence
+(
+ NSSPKIXName *name,
+ NSSArena *arenaOpt
+)
+{
+#ifdef NSSDEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return (NSSPKIXRDNSequence *)NULL;
+ }
+
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSPKIXRDNSequence *)NULL;
+ }
+ }
+#endif /* NSSDEBUG */
+
+ switch( name->choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ return nssPKIXRDNSequence_Duplicate(name->u.rdnSequence, arenaOpt);
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ break;
+ }
+
+ nss_SetError(NSS_ERROR_WRONG_CHOICE);
+ return (NSSPKIXRDNSequence *)NULL;
+}
diff --git a/security/nss/lib/pkix/src/Name/PGetSpecifiedChoice.c b/security/nss/lib/pkix/src/Name/PGetSpecifiedChoice.c
new file mode 100644
index 000000000..a24c8ea86
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PGetSpecifiedChoice.c
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_GetSpecifiedChoice
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_WRONG_CHOICE
+ *
+ * Return value:
+ * A valid pointer ...
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT void *
+nssPKIXName_GetSpecifiedChoice
+(
+ NSSPKIXName *name,
+ NSSPKIXNameChoice choice,
+ NSSArena *arenaOpt
+)
+{
+#ifdef NSSDEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return (void *)NULL;
+ }
+
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (void *)NULL;
+ }
+ }
+#endif /* NSSDEBUG */
+
+ if( choice != name->choice ) {
+ nss_SetError(NSS_ERROR_WRONG_CHOICE);
+ return (void *)NULL;
+ }
+
+ switch( name->choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ return (void *)nssPKIXRDNSequence_Duplicate(name->u.rdnSequence, arenaOpt);
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ break;
+ }
+
+ nss_SetError(NSS_ERROR_WRONG_CHOICE);
+ return (NSSPKIXRDNSequence *)NULL;
+}
diff --git a/security/nss/lib/pkix/src/Name/PGetUTF8Encoding.c b/security/nss/lib/pkix/src/Name/PGetUTF8Encoding.c
new file mode 100644
index 000000000..164229277
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/PGetUTF8Encoding.c
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+/*
+ * nssPKIXName_GetUTF8Encoding
+ *
+ * -- fgmr comments --
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_NAME
+ * NSS_ERROR_INVALID_ARENA
+ * NSS_ERROR_NO_MEMORY
+ *
+ * Return value:
+ * A valid NSSUTF8 pointer upon success
+ * NULL upon failure
+ */
+
+NSS_IMPLEMENT NSSUTF8 *
+nssPKIXName_GetUTF8Encoding
+(
+ NSSPKIXName *name,
+ NSSArena *arenaOpt
+)
+{
+#ifdef NSSDEBUG
+ if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) {
+ return (NSSUTF8 *)NULL;
+ }
+
+ if( (NSSArena *)NULL != arenaOpt ) {
+ if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
+ return (NSSUTF8 *)NULL;
+ }
+ }
+#endif /* NSSDEBUG */
+
+ if( (NSSUTF8 *)NULL == name->utf8 ) {
+ /* xxx fgmr fill this in from pki1 implementation */
+ }
+
+ return nssUTF8_Duplicate(name->utf8, arenaOpt);
+}
diff --git a/security/nss/lib/pkix/src/Name/template.c b/security/nss/lib/pkix/src/Name/template.c
new file mode 100644
index 000000000..72ac85466
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/template.c
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIX_H
+#include "pkix.h"
+#endif /* PKIX_H */
+
+#ifndef ASN1_H
+#include "asn1.h"
+#endif /* ASN1_H */
+
+/*
+ * nssPKIXName_template
+ *
+ */
+
+const nssASN1Template nssPKIXName_template[] = {
+ { nssASN1_CHOICE, offsetof(NSSPKIXName, choice), 0, sizeof(NSSPKIXName) },
+ { nssASN1_POINTER, offsetof(NSSPKIXName, u.rdnSequence),
+ nssPKIXRDNSequence_template, NSSPKIXNameChoice_rdnSequence },
+ { 0 }
+};
diff --git a/security/nss/lib/pkix/src/Name/verifyPointer.c b/security/nss/lib/pkix/src/Name/verifyPointer.c
new file mode 100644
index 000000000..6c27e5910
--- /dev/null
+++ b/security/nss/lib/pkix/src/Name/verifyPointer.c
@@ -0,0 +1,210 @@
+/*
+ * 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.
+ */
+
+#ifdef DEBUG
+static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$";
+#endif /* DEBUG */
+
+#ifndef PKIXM_H
+#include "pkixm.h"
+#endif /* PKIXM_H */
+
+#ifdef DEBUG
+
+extern const NSSError NSS_ERROR_INTERNAL_ERROR;
+
+static nssPointerTracker pkix_name_pointer_tracker;
+
+/*
+ * nss_pkix_Name_add_pointer
+ *
+ * This method is only present in debug builds.
+ *
+ * This module-private routine adds an NSSPKIXName pointer to
+ * the internal pointer-tracker. This routine should only be used
+ * by the NSSPKIX module. This routine returns a PRStatus value;
+ * upon error it will place an error on the error stack and return
+ * PR_FAILURE.
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_NO_MEMORY
+ * NSS_ERROR_INTERNAL_ERROR
+ *
+ * Return value:
+ * PR_SUCCESS upon success
+ * PR_FAILURE upon failure
+ */
+
+NSS_IMPLEMENT PRStatus
+nss_pkix_Name_add_pointer
+(
+ const NSSPKIXName *p
+)
+{
+ PRStatus rv;
+
+ rv = nssPointerTracker_initialize(&pkix_name_pointer_tracker);
+ if( PR_SUCCESS != rv ) {
+ return rv;
+ }
+
+ rv = nssPointerTracker_add(&pkix_name_pointer_tracker, p);
+ if( PR_SUCCESS != rv ) {
+ NSSError e = NSS_GetError();
+ if( NSS_ERROR_NO_MEMORY != e ) {
+ nss_SetError(NSS_ERROR_INTERNAL_ERROR);
+ }
+
+ return rv;
+ }
+
+ rv = nssArena_registerDestructor(p->arena,
+ nss_pkix_Name_remove_pointer, p);
+ if( PR_SUCCESS != rv ) {
+ (void)nss_pkix_Name_remove_pointer(p);
+ return rv;
+ }
+
+#ifdef NSSDEBUG
+ switch( p->choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ rv = nss_pkix_RDNSequence_register(p->u.rdnSequence);
+ break;
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ nss_SetError(NSS_ERROR_INTERNAL_ERROR);
+ rv = PR_FAILURE;
+ break;
+ }
+
+ if( PR_SUCCESS != rv ) {
+ (void)nss_pkix_Name_remove_pointer(p);
+ }
+#endif /* NSSDEBUG */
+
+ return rv;
+}
+
+/*
+ * nss_pkix_Name_remove_pointer
+ *
+ * This method is only present in debug builds.
+ *
+ * This module-private routine removes a valid NSSPKIXName
+ * pointer from the internal pointer-tracker. This routine should
+ * only be used by the NSSPKIX module. This routine returns a
+ * PRStatus value; upon error it will place an error on the error
+ * stack and return PR_FAILURE.
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INTERNAL_ERROR
+ *
+ * Return value:
+ * PR_SUCCESS upon success
+ * PR_FAILURE upon failure
+ */
+
+NSS_IMPLEMENT PRStatus
+nss_pkix_Name_remove_pointer
+(
+ const NSSPKIXName *p
+)
+{
+ PRStatus rv;
+
+ rv = nssPointerTracker_remove(&pkix_name_pointer_tracker, p);
+ if( PR_SUCCESS != rv ) {
+ nss_SetError(NSS_ERROR_INTERNAL_ERROR);
+ }
+
+#ifdef NSSDEBUG
+ switch( p->choice ) {
+ case NSSPKIXNameChoice_rdnSequence:
+ (void)nss_pkix_RDNSequence_register(p->u.rdnSequence);
+ break;
+ case NSSPKIXNameChoice_NSSinvalid:
+ default:
+ break;
+ }
+#endif /* NSSDEBUG */
+
+ /*
+ * nssArena_deregisterDestructor(p->arena,
+ * nss_pkix_Name_remove_pointer, p);
+ */
+
+ return rv;
+}
+
+/*
+ * nssPKIXName_verifyPointer
+ *
+ * This method is only present in debug builds.
+ *
+ * If the specified pointer is a valid pointer to an NSSPKIXName
+ * object, this routine will return PR_SUCCESS. Otherwise, it will
+ * put an error on the error stack and return PR_FAILURE.
+ *
+ * The error may be one of the following values:
+ * NSS_ERROR_INVALID_PKIX_ATTRIBUTE
+ *
+ * Return value:
+ * PR_SUCCESS if the pointer is valid
+ * PR_FAILURE if it isn't
+ */
+
+NSS_IMPLEMENT PRStatus
+nssPKIXName_verifyPointer
+(
+ NSSPKIXName *p
+)
+{
+ PRStatus rv;
+
+ rv = nssPointerTracker_initialize(&pkix_name_pointer_tracker);
+ if( PR_SUCCESS != rv ) {
+ nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE);
+ return PR_FAILURE;
+ }
+
+ rv = nssPointerTracker_verify(&pkix_name_pointer_tracker, p);
+ if( PR_SUCCESS != rv ) {
+ nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE);
+ return PR_FAILURE;
+ }
+
+ return PR_SUCCESS;
+}
+
+#endif /* DEBUG */
+