diff options
Diffstat (limited to 'security/nss/lib/pkix/src/RelativeDistinguishedName')
39 files changed, 4007 insertions, 0 deletions
diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/AddAttributeTypeAndValue.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/AddAttributeTypeAndValue.c new file mode 100644 index 000000000..efb142396 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/AddAttributeTypeAndValue.c @@ -0,0 +1,77 @@ +/* + * 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 */ + +/* + * NSSPKIXRelativeDistinguishedName_AddAttributeTypeAndValue + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRelativeDistinguishedName_AddAttributeTypeAndValue +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSPKIXAttributeTypeAndValue *atav +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_AddAttributeTypeAndValue(rdn, atav); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/Create.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/Create.c new file mode 100644 index 000000000..52e139c69 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/Create.c @@ -0,0 +1,125 @@ +/* + * 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 */ + +/* + * NSSPKIXRelativeDistinguishedName_Create + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_ATAV + * + * Return value: + * A valid pointer to an NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_EXTERN NSSPKIXRelativeDistinguishedName * +NSSPKIXRelativeDistinguishedName_Create +( + NSSArena *arenaOpt, + NSSPKIXAttributeTypeAndValue *atav1, + ... +) +{ + va_list ap; + NSSPKIXRelativeDistinguishedName *rv; + PRUint32 count; + + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } + + /* Is there a nonzero minimum number of ATAVs required? */ + + { + va_start(ap, arenaOpt); + + while( 1 ) { + NSSPKIXAttributeTypeAndValue *atav; + atav = (NSSPKIXAttributeTypeAndValue *)va_arg(ap, NSSPKIXAttributeTypeAndValue *); + if( (NSSPKIXAttributeTypeAndValue *)NULL == atav ) { + break; + } + + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + va_end(ap); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } + + va_end(ap); + } +#endif /* DEBUG */ + + va_start(ap, arenaOpt); + + for( count = 0; ; count++ ) { + NSSPKIXAttributeTypeAndValue *atav; + atav = (NSSPKIXAttributeTypeAndValue *)va_arg(ap, NSSPKIXAttributeTypeAndValue *); + if( (NSSPKIXAttributeTypeAndValue *)NULL == atav ) { + break; + } + +#ifdef PEDANTIC + if( count == 0xFFFFFFFF ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + va_end(ap); + return (NSSPKIXAttributeTypeAndValue *)NULL; + } +#endif /* PEDANTIC */ + } + + va_end(ap); + + va_start(ap, arenaOpt); + rv = nss_pkix_RelativeDistinguishedName_V_Create(arenaOpt, count, ap); + va_end(ap); + + return rv; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/CreateFromArray.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/CreateFromArray.c new file mode 100644 index 000000000..0c01be4da --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/CreateFromArray.c @@ -0,0 +1,86 @@ +/* + * 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 */ + +/* + * NSSPKIXRelativeDistinguishedName_CreateFromArray + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_ATAV + * + * Return value: + * A valid pointer to an NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +NSSPKIXRelativeDistinguishedName_CreateFromArray +( + NSSArena *arenaOpt, + PRUint32 count, + NSSPKIXAttributeTypeAndValue *atavs[] +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } + + { + PRUint32 i; + + for( i = 0; i < count; i++ ) { + if( PR_SUCCESS != nssAttributeTypeAndValue_verifyPointer(&atavs[i]) ) { + return (NSSPKIXAttribute *)NULL; + } + } + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_CreateFromArray(arenaOpt, count, atavs); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/CreateFromUTF8.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/CreateFromUTF8.c new file mode 100644 index 000000000..990b7acd2 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/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 */ + +/* + * NSSPKIXRelativeDistinguishedName_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 NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +NSSPKIXRelativeDistinguishedName_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *string +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } + + if( (NSSUTF8 *)NULL == string ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_CreateFromUTF8(arenaOpt, string); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/Decode.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/Decode.c new file mode 100644 index 000000000..b8d0b243a --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/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 */ + +/* + * NSSPKIXRelativeDistinguishedName_Decode + * + * -- 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 NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +NSSPKIXRelativeDistinguishedName_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_Decode(arenaOpt, ber); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/Destroy.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/Destroy.c new file mode 100644 index 000000000..ca8b1e85f --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/Destroy.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 */ + +/* + * NSSPKIXRelativeDistinguishedName_Destroy + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRelativeDistinguishedName_Destroy +( + NSSPKIXRelativeDistinguishedName *rdn +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_Destroy(rdn); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/Duplicate.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/Duplicate.c new file mode 100644 index 000000000..416b405e8 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/Duplicate.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 */ + +/* + * NSSPKIXRelativeDistinguishedName_Duplicate + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +NSSPKIXRelativeDistinguishedName_Duplicate +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_Duplicate(rdn, arenaOpt); +} + diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/Encode.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/Encode.c new file mode 100644 index 000000000..ea6b82a55 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/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 */ + +/* + * NSSPKIXRelativeDistinguishedName_Encode + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +NSSPKIXRelativeDistinguishedName_Encode +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_Encode(rdn, encoding, rvOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/Equal.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/Equal.c new file mode 100644 index 000000000..3e4a3fc3e --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/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 */ + +/* + * NSSPKIXRelativeDistinguishedName_Equal + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_EXTERN PRBool +NSSPKIXRelativeDistinguishedName_Equal +( + NSSPKIXRelativeDistinguishedName *one, + NSSPKIXRelativeDistinguishedName *two, + PRStatus *statusOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(one) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(two) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_Equal(one, two, statusOpt); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/FindAttributeTypeAndValue.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/FindAttributeTypeAndValue.c new file mode 100644 index 000000000..65032b1c1 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/FindAttributeTypeAndValue.c @@ -0,0 +1,78 @@ +/* + * 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 */ + +/* + * NSSPKIXRelativeDistinguishedName_FindAttributeTypeAndValue + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_NOT_FOUND + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * The index of the specified attribute value upon success + * -1 upon failure. + */ + +NSS_EXTERN PRInt32 +NSSPKIXRelativeDistinguishedName_FindAttributeTypeAndValue +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSPKIXAttributeTypeAndValue *atav +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_FindAttributeTypeAndValue(rdn, atav); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/GetAttributeTypeAndValue.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/GetAttributeTypeAndValue.c new file mode 100644 index 000000000..1a58bd132 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/GetAttributeTypeAndValue.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 */ + +/* + * NSSPKIXRelativeDistinguishedName_GetAttributeTypeAndValue + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXAttributeTypeAndValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue * +NSSPKIXRelativeDistinguishedName_GetAttributeTypeAndValue +( + NSSPKIXRelativeDistinguishedName *rdn, + PRInt32 i, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_GetAttributeTypeAndValue(rdn, i, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/GetAttributeTypeAndValueCount.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/GetAttributeTypeAndValueCount.c new file mode 100644 index 000000000..1209e726c --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/GetAttributeTypeAndValueCount.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 */ + +/* + * NSSPKIXRelativeDistinguishedName_GetAttributeTypeAndValueCount + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * Nonnegative integer upon success + * -1 upon failure. + */ + +NSS_IMPLEMENT PRInt32 +NSSPKIXRelativeDistinguishedName_GetAttributeTypeAndValueCount +( + NSSPKIXRelativeDistinguishedName *rdn +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return -1; + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_GetAttributeTypeAndValueCount(rdn); +} + diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/GetAttributeTypeAndValues.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/GetAttributeTypeAndValues.c new file mode 100644 index 000000000..7efc30173 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/GetAttributeTypeAndValues.c @@ -0,0 +1,83 @@ +/* + * 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 */ + +/* + * NSSPKIXRelativeDistinguishedName_GetAttributeTypeAndValues + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_ARRAY_TOO_SMALL + * + * Return value: + * A valid pointer to an array of NSSPKIXAttributeTypeAndValue + * pointers upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue ** +NSSPKIXRelativeDistinguishedName_GetAttributeTypeAndValues +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSPKIXAttributeTypeAndValue *rvOpt[], + PRInt32 limit, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return (NSSPKIXAttributeTypeAndValue **)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyOpt(attribute) ) { + return (NSSPKIXAttributeTypeAndValue **)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_GetAttributeTypeAndValues(rdn, rvOpt, limit, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/GetUTF8Encoding.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/GetUTF8Encoding.c new file mode 100644 index 000000000..9c428ae40 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/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 */ + +/* + * NSSPKIXRelativeDistinguishedName_GetUTF8Encoding + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSUTF8 pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSUTF8 * +NSSPKIXRelativeDistinguishedName_GetUTF8Encoding +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_GetUTF8Encoding(rdn, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/MClear.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/MClear.c new file mode 100644 index 000000000..2b1a93820 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/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_RelativeDistinguishedName_Clear + * + * Wipes out cached data. + */ + +NSS_IMPLEMENT PRStatus +nss_pkix_RelativeDistinguishedName_Clear +( + NSSPKIXRelativeDistinguishedName *rdn +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( (NSSBER *)NULL != rdn->ber ) { + nss_ZFreeIf(rdn->ber->data); + nss_ZFreeIf(rdn->ber); + } + + if( (NSSDER *)NULL != rdn->der ) { + nss_ZFreeIf(rdn->der->data); + nss_ZFreeIf(rdn->der); + } + + nss_ZFreeIf(rdn->utf8); + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/MCount.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/MCount.c new file mode 100644 index 000000000..23d976160 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/MCount.c @@ -0,0 +1,82 @@ +/* + * 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 */ + +/* + * nss_pkix_RelativeDistinguishedName_Count + */ + +NSS_IMPLEMENT void +nss_pkix_RelativeDistinguishedName_Count +( + NSSPKIXRelativeDistinguishedName *rdn +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return; + } +#endif /* NSSDEBUG */ + + PR_ASSERT((NSSPKIXAttributeTypeAndValue **)NULL != rdn->atavs); + if( (NSSPKIXAttributeTypeAndValue **)NULL == rdn->atavs ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + return PR_FAILURE; + } + + if( 0 == rdn->count ) { + PRUint32 i; + for( i = 0; i < 0xFFFFFFFF; i++ ) { + if( (NSSPKIXAttributeTypeAndValue *)NULL == rdn->atavs[i] ) { + break; + } + } + +#ifdef PEDANTIC + if( 0xFFFFFFFF == i ) { + return; + } +#endif /* PEDANTIC */ + + rdn->count = i; + } + + return; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/MVCreate.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/MVCreate.c new file mode 100644 index 000000000..c40a4b6e7 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/MVCreate.c @@ -0,0 +1,158 @@ +/* + * 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 */ + +/* + * nss_pkix_RelativeDistinguishedName_v_create + * + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_OID + * NSS_ERROR_INVALID_ITEM + * + * Return value: + * A valid pointer to an NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure. + */ + +NSS_EXTERN NSSPKIXRelativeDistinguishedName * +nss_pkix_RelativeDistinguishedName_V_Create +( + NSSArena *arenaOpt, + PRUint32 count, + va_list ap +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXRelativeDistinguishedName *rv = (NSSPKIXRelativeDistinguishedName *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)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, NSSPKIXRelativeDistinguishedName); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + rv->count = count; + + rv->atav = nss_ZNEWARRAY(arena, NSSPKIXAttributeTypeAndValue *, count); + if( (NSSPKIXAttributeTypeAndValue **)NULL == rv->atav ) { + goto loser; + } + + for( i = 0; i < count; i++ ) { + NSSPKIXAttributeTypeAndValue *v = (NSSPKIXAttributeTypeAndValue *) + va_arg(ap, NSSPKIXAttributeTypeAndValue *); + +#ifdef NSSDEBUG + /* + * It's okay to test this down here, since + * supposedly these have already been checked. + */ + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(v) ) { + goto loser; + } +#endif /* NSSDEBUG */ + + rv->atav[i] = nssPKIXAttributeTypeAndValue_Duplicate(v, arena); + if( (NSSPKIXAttributeTypeAndValue *)NULL == rv->atav[i] ) { + goto loser; + } + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_RelativeDistinguishedName_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != nssArena_registerDestructor(arena, + nss_pkix_RelativeDistinguishedName_remove_pointer, rv) ) { + (void)nss_pkix_RelativeDistinguishedName_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 (NSSPKIXRelativeDistinguishedName *)NULL; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PAddAttributeTypeAndValue.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PAddAttributeTypeAndValue.c new file mode 100644 index 000000000..68541d17e --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PAddAttributeTypeAndValue.c @@ -0,0 +1,107 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_AddAttributeTypeAndValue + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRelativeDistinguishedName_AddAttributeTypeAndValue +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSPKIXAttributeTypeAndValue *atav +) +{ + PRUint32 newcount; + NSSPKIXAttributeTypeAndValue **newarray; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + PR_ASSERT((NSSPKIXAttributeTypeAndValue **)NULL != rdn->atavs); + if( (NSSPKIXAttributeTypeAndValue **)NULL == rdn->atavs ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + return PR_FAILURE; + } + + if( 0 == rdn->count ) { + nss_pkix_RelativeDistinguishedName_Count(rdn); + } + + newcount = rdn->count+1; + /* Check newcount for a rollover. */ + + /* Remember that our atavs array is NULL-terminated */ + newarray = (NSSPKIXAttributeTypeAndValue **)nss_ZRealloc(rdn->atavs, + ((newcount+1) * sizeof(NSSPKIXAttributeTypeAndValue *))); + if( (NSSPKIXAttributeTypeAndValue **)NULL == newarray ) { + return PR_FAILURE; + } + + rdn->atavs = newarray; + + rdn->atavs[ rdn->count ] = nssPKIXAttributeTypeAndValue_Duplicate(atav, rdn->arena); + if( (NSSPKIXAttributeTypeAndValue *)NULL == rdn->atavs[ rdn->count ] ) { + return PR_FAILURE; /* array is "too big" but whatever */ + } + + rdn->count = newcount; + + return nss_pkix_RelativeDistinguishedName_Clear(rdn); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PCreate.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PCreate.c new file mode 100644 index 000000000..a3a1f7315 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PCreate.c @@ -0,0 +1,123 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_Create + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_ATAV + * + * Return value: + * A valid pointer to an NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +nssPKIXRelativeDistinguishedName_Create +( + NSSArena *arenaOpt, + NSSPKIXAttributeTypeAndValue *atav1, + ... +) +{ + va_list ap; + NSSPKIXRelativeDistinguishedName *rv; + PRUint32 count; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } + + /* Is there a nonzero minimum number of ATAVs required? */ + + { + va_start(ap, arenaOpt); + + while( 1 ) { + NSSPKIXAttributeTypeAndValue *atav; + atav = (NSSPKIXAttributeTypeAndValue *)va_arg(ap, NSSPKIXAttributeTypeAndValue *); + if( (NSSPKIXAttributeTypeAndValue *)NULL == atav ) { + break; + } + + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + va_end(ap); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } + + va_end(ap); + } +#endif /* NSSDEBUG */ + + va_start(ap, arenaOpt); + + for( count = 0; ; count++ ) { + NSSPKIXAttributeTypeAndValue *atav; + atav = (NSSPKIXAttributeTypeAndValue *)va_arg(ap, NSSPKIXAttributeTypeAndValue *); + if( (NSSPKIXAttributeTypeAndValue *)NULL == atav ) { + break; + } + +#ifdef PEDANTIC + if( count == 0xFFFFFFFF ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + va_end(ap); + return (NSSPKIXAttributeTypeAndValue *)NULL; + } +#endif /* PEDANTIC */ + } + + va_end(ap); + + va_start(ap, arenaOpt); + rv = nss_pkix_RelativeDistinguishedName_V_Create(arenaOpt, count, ap); + va_end(ap); + + return rv; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PCreateFromArray.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PCreateFromArray.c new file mode 100644 index 000000000..fa7e27eed --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PCreateFromArray.c @@ -0,0 +1,151 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_CreateFromArray + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_ATAV + * + * Return value: + * A valid pointer to an NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +nssPKIXRelativeDistinguishedName_CreateFromArray +( + NSSArena *arenaOpt, + PRUint32 count, + NSSPKIXAttributeTypeAndValue *atavs +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXRelativeDistinguishedName *rv = (NSSPKIXRelativeDistinguishedName *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } + + { + PRUint32 i; + + for( i = 0; i < count; i++ ) { + if( PR_SUCCESS != nssAttributeTypeAndValue_verifyPointer(&atavs[i]) ) { + return (NSSPKIXAttribute *)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, NSSPKIXRelativeDistinguishedName); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + rv->count = count; + + rv->atav = nss_ZNEWARRAY(arena, NSSPKIXAttributeTypeAndValue *, count); + if( (NSSPKIXAttributeTypeAndValue **)NULL == rv->atav ) { + goto loser; + } + + for( i = 0; i < count; i++ ) { + NSSPKIXAttributeTypeAndValue *v = atavs[i]; + + rv->atav[i] = nssPKIXAttributeTypeAndValue_Duplicate(v, arena); + if( (NSSPKIXAttributeTypeAndValue *)NULL == rv->atav[i] ) { + goto loser; + } + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_RelativeDistinguishedName_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 (NSSPKIXRelativeDistinguishedName *)NULL; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PCreateFromUTF8.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PCreateFromUTF8.c new file mode 100644 index 000000000..2f2f995be --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PCreateFromUTF8.c @@ -0,0 +1,139 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_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 NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +nssPKIXRelativeDistinguishedName_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *string +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXRelativeDistinguishedName *rv = (NSSPKIXRelativeDistinguishedName *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } + + if( (NSSUTF8 *)NULL == string ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXRelativeDistinguishedName *)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, NSSPKIXRelativeDistinguishedName); + if( (NSSPKIXRelativeDistinguishedName *)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_RelativeDistinguishedName_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 (NSSPKIXRelativeDistinguishedName *)NULL; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PDecode.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PDecode.c new file mode 100644 index 000000000..ad1766280 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PDecode.c @@ -0,0 +1,142 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_Decode + * + * -- 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 NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +nssPKIXRelativeDistinguishedName_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXRelativeDistinguishedName *rv = (NSSPKIXRelativeDistinguishedName *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXRelativeDistinguishedName *)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, NSSPKIXRelativeDistinguishedName); + if( (NSSPKIXRelativeDistinguishedName *)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, nssPKIXRelativeDistinguishedName_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_RelativeDistinguishedName_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 (NSSPKIXRelativeDistinguishedName *)NULL; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PDestroy.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PDestroy.c new file mode 100644 index 000000000..94b8fcf00 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/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 */ + +/* + * nssPKIXRelativeDistinguishedName_Destroy + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRelativeDistinguishedName_Destroy +( + NSSPKIXRelativeDistinguishedName *rdn +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + +#ifdef DEBUG + (void)nss_pkix_RelativeDistinguishedName_remove_pointer(rdn); +#endif /* DEBUG */ + + if( PR_TRUE == rdn->i_allocated_arena ) { + return nssArena_Destroy(rdn->arena); + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PDuplicate.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PDuplicate.c new file mode 100644 index 000000000..0277b7b01 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PDuplicate.c @@ -0,0 +1,177 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_Duplicate + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +nssPKIXRelativeDistinguishedName_Duplicate +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSArena *arenaOpt +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXRelativeDistinguishedName *rv = (NSSPKIXRelativeDistinguishedName *)NULL; + PRStatus status; + PRUint32 i; + NSSPKIXAttributeTypeAndValue **from, **to; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)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, NSSPKIXRelativeDistinguishedName); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + + if( (NSSDER *)NULL != rdn->der ) { + rv->der = nssItem_Duplicate(rdn->der, arena, (NSSItem *)NULL); + if( (NSSDER *)NULL == rv->der ) { + goto loser; + } + } + + if( (NSSBER *)NULL != rdn->ber ) { + rv->ber = nssItem_Duplicate(rdn->ber, arena, (NSSItem *)NULL); + if( (NSSBER *)NULL == rv->ber ) { + goto loser; + } + } + + if( (NSSUTF8 *)NULL != rdn->utf8 ) { + rv->utf8 = nssUTF8_Duplicate(rdn->utf8, arena); + if( (NSSUTF8 *)NULL == rv->utf8 ) { + goto loser; + } + } + + rv->count = rdn->count; + + { + if( 0 == rdn->count ) { + nss_pkix_RelativeDistinguishedName_Count(rdn); + if( 0 == rdn->count ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + goto loser; + } + + rv->count = rdn->count; /* might as well save it */ + } + + rv->atavs = nss_ZNEWARRAY(arena, NSSPKIXAttributeTypeAndValue *, rdn->count + 1); + if( (NSSPKIXAttributeTypeAndValue *)NULL == rv->atavs ) { + goto loser; + } + } + + for( from = &rdn->atavs[0], to = &rv->atavs[0]; *from; from++, to++ ) { + *to = nssPKIXAttributeTypeAndValue_Duplicate(*from, arena); + if( (NSSPKIXAttributeTypeAndValue *)NULL == *to ) { + goto loser; + } + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_RelativeDistinguishedName_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 (NSSPKIXRelativeDistinguishedName *)NULL; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PEncode.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PEncode.c new file mode 100644 index 000000000..d2af9470b --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PEncode.c @@ -0,0 +1,123 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_Encode + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +nssPKIXRelativeDistinguishedName_Encode +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + NSSBER *it; + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + 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 != rdn->ber ) { + it = rdn->ber; + goto done; + } + /*FALLTHROUGH*/ + case NSSASN1DER: + if( (NSSDER *)NULL != rdn->der ) { + it = rdn->der; + goto done; + } + break; + default: + nss_SetError(NSS_ERROR_UNSUPPORTED_ENCODING); + return (NSSBER *)NULL; + } + + it = nssASN1_EncodeItem(rdn->arena, (NSSItem *)NULL, rdn, + nssPKIXRelativeDistinguishedName_template, + encoding); + if( (NSSBER *)NULL == it ) { + return (NSSBER *)NULL; + } + + switch( encoding ) { + case NSSASN1BER: + rdn->ber = it; + break; + case NSSASN1DER: + rdn->der = it; + break; + default: + PR_ASSERT(0); + break; + } + + done: + return nssItem_Duplicate(it, arenaOpt, rvOpt); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PEqual.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PEqual.c new file mode 100644 index 000000000..2ac566a8b --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PEqual.c @@ -0,0 +1,101 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_Equal + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +nssPKIXRelativeDistinguishedName_Equal +( + NSSPKIXRelativeDistinguishedName *one, + NSSPKIXRelativeDistinguishedName *two, + PRStatus *statusOpt +) +{ + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(one) ) { + goto loser; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(two) ) { + goto loser; + } +#endif /* NSSDEBUG */ + + if( (NSSDER *)NULL == one->der ) { + one->der = nssASN1_EncodeItem(one->arena, (NSSItem *)NULL, one, + nssPKIXRelativeDistinguishedName_template, + NSSASN1DER); + if( (NSSDER *)NULL == one->der ) { + goto loser; + } + } + + if( (NSSDER *)NULL == two->der ) { + two->der = nssASN1_EncodeItem(two->arena, (NSSItem *)NULL, two, + nssPKIXRelativeDistinguishedName_template, + NSSASN1DER); + if( (NSSDER *)NULL == two->der ) { + goto loser; + } + } + + return nssItem_Equal(one->der, two->der, statusOpt); + + loser: + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PFindAttributeTypeAndValue.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PFindAttributeTypeAndValue.c new file mode 100644 index 000000000..ee7c55e10 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PFindAttributeTypeAndValue.c @@ -0,0 +1,96 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_FindAttributeTypeAndValue + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_NOT_FOUND + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * The index of the specified attribute value upon success + * -1 upon failure. + */ + +NSS_IMPLEMENT PRInt32 +nssPKIXRelativeDistinguishedName_FindAttributeTypeAndValue +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSPKIXAttributeTypeAndValue *atav +) +{ + PRUint32 i; + NSSPKIXAttributeTypeAndValue **a; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return -1; + } + + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return -1; + } +#endif /* NSSDEBUG */ + + PR_ASSERT((NSSPKIXAttributeTypeAndValue **)NULL != rdn->atavs); + if( (NSSPKIXAttributeTypeAndValue **)NULL == rdn->atavs ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + return -1; + } + + for( i = 0, a = rdn->atavs; *a; a++, (i > 0x7fffffff) || i++ ) { + if( PR_TRUE == nssPKIXAttributeTypeAndValue_Equal(*a, atav) ) { + if( i > 0x7fffffff ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return -1; + } + return (PRInt32)i; + } + } + + nss_SetError(NSS_ERROR_NOT_FOUND); + return -1; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetAttributeTypeAndValue.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetAttributeTypeAndValue.c new file mode 100644 index 000000000..22c3abac6 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetAttributeTypeAndValue.c @@ -0,0 +1,89 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_GetAttributeTypeAndValue + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXAttributeTypeAndValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue * +nssPKIXRelativeDistinguishedName_GetAttributeTypeAndValue +( + NSSPKIXRelativeDistinguishedName *rdn, + PRInt32 i, + NSSArena *arenaOpt +) +{ + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( 0 == rdn->count ) { + nss_pkix_RelativeDistinguishedName_Count(rdn); + } + + if( (i < 0) || (i >= rdn->count) ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + + return nssPKIXAttributeTypeAndValue_Duplicate(rdn->atavs[i], arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetAttributeTypeAndValueCount.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetAttributeTypeAndValueCount.c new file mode 100644 index 000000000..df8e1b48e --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetAttributeTypeAndValueCount.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 */ + +/* + * nssPKIXRelativeDistinguishedName_GetAttributeTypeAndValueCount + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * Nonnegative integer upon success + * -1 upon failure. + */ + +NSS_IMPLEMENT PRInt32 +nssPKIXRelativeDistinguishedName_GetAttributeTypeAndValueCount +( + NSSPKIXRelativeDistinguishedName *rdn +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return -1; + } +#endif /* NSSDEBUG */ + + if( 0 == rdn->count ) { + nss_pkix_RelativeDistinguishedName_Count(rdn); + } + +#ifdef PEDANTIC + if( 0 == rdn->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return -1; + } +#endif /* PEDANTIC */ + + if( rdn->count > 0x7fffffff ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return -1; + } + + return (PRInt32)(rdn->count); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetAttributeTypeAndValues.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetAttributeTypeAndValues.c new file mode 100644 index 000000000..7675d5ad3 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetAttributeTypeAndValues.c @@ -0,0 +1,133 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_GetAttributeTypeAndValues + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_ARRAY_TOO_SMALL + * + * Return value: + * A valid pointer to an array of NSSPKIXAttributeTypeAndValue + * pointers upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue ** +nssPKIXRelativeDistinguishedName_GetAttributeTypeAndValues +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSPKIXAttributeTypeAndValue *rvOpt[], + PRInt32 limit, + NSSArena *arenaOpt +) +{ + NSSPKIXAttributeTypeAndValue **rv = (NSSPKIXAttributeTypeAndValue **)NULL; + PRUint32 i; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return (NSSPKIXAttributeTypeAndValue **)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyOpt(attribute) ) { + return (NSSPKIXAttributeTypeAndValue **)NULL; + } + } +#endif /* NSSDEBUG */ + + if( 0 == rdn->count ) { + nss_pkix_RelativeDistinguishedName_Count(rdn); + } + +#ifdef PEDANTIC + if( 0 == rdn->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXAttributeTypeAndValue **)NULL; + } +#endif /* PEDANTIC */ + + if( (limit < rdn->count) && + !((0 == limit) && ((NSSPKIXAttributeTypeAndValue **)NULL == rvOpt)) ) { + nss_SetError(NSS_ERROR_ARRAY_TOO_SMALL); + return (NSSPKIXAttributeTypeAndValue **)NULL; + } + + limit = rdn->count; + if( (NSSPKIXAttributeTypeAndValue **)NULL == rvOpt ) { + rv = nss_ZNEWARRAY(arenaOpt, NSSPKIXAttributeTypeAndValue *, limit); + if( (NSSPKIXAttributeTypeAndValue **)NULL == rv ) { + return (NSSPKIXAttributeTypeAndValue **)NULL; + } + } else { + rv = rvOpt; + } + + for( i = 0; i < limit; i++ ) { + rv[i] = nssPKIXAttributeTypeAndValue_Duplicate(rdn->atav[i], arenaOpt); + if( (NSSPKIXAttributeTypeAndValue *)NULL == rv[i] ) { + goto loser; + } + } + + return rv; + + loser: + for( i = 0; i < limit; i++ ) { + NSSPKIXAttributeTypeAndValue *x = rv[i]; + if( (NSSPKIXAttributeTypeAndValue *)NULL == x ) { + break; + } + (void)nssPKIXAttributeTypeAndValue_Destroy(x); + } + + if( rv != rvOpt ) { + nss_ZFreeIf(rv); + } + + return (NSSPKIXAttributeTypeAndValue **)NULL; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetUTF8Encoding.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PGetUTF8Encoding.c new file mode 100644 index 000000000..01abf228c --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/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 */ + +/* + * nssPKIXRelativeDistinguishedName_GetUTF8Encoding + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSUTF8 pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSUTF8 * +nssPKIXRelativeDistinguishedName_GetUTF8Encoding +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSArena *arenaOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( (NSSUTF8 *)NULL == rdn->utf8 ) { + /* xxx fgmr fill this in from pki1 implementation */ + } + + return nssUTF8_Duplicate(rdn->utf8, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PRemoveAttributeTypeAndValue.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PRemoveAttributeTypeAndValue.c new file mode 100644 index 000000000..84b5cc819 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PRemoveAttributeTypeAndValue.c @@ -0,0 +1,121 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_RemoveAttributeTypeAndValue + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_AT_MINIMUM + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRelativeDistinguishedName_RemoveAttributeTypeAndValue +( + NSSPKIXRelativeDistinguishedName *rdn, + PRInt32 i +) +{ + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( 0 == rdn->count ) { + nss_pkix_RelativeDistinguishedName_Count(rdn); + } + + if( i < 0 ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } + + /* Is there a technical minimum? */ + /* + * if( 1 == rdn->count ) { + * nss_SetError(NSS_ERROR_AT_MINIMUM); + * return PR_FAILURE; + * } + */ + +#ifdef PEDANTIC + if( 0 == rdn->count ) { + NSSPKIXAttributeTypeAndValue **ip; + /* Too big.. but we can still remove one */ + nssPKIXAttributeTypeAndValue_Destroy(rdn->atavs[i]); + for( ip = &rdn->atavs[i]; *ip; ip++ ) { + ip[0] = ip[1]; + } + } else +#endif /* PEDANTIC */ + + { + NSSPKIXAttributeTypeAndValue *si; + PRUint32 end; + + if( i >= rdn->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } + + end = rdn->count - 1; + + si = rdn->atavs[i]; + rdn->atavs[i] = rdn->atavs[end]; + rdn->atavs[end] = (NSSPKIXAttributeTypeAndValue *)NULL; + + nssPKIXAttributeTypeAndValue_Destroy(si); + + /* We could realloc down, but we know it's a no-op */ + rdn->count = end; + } + + return nss_pkix_RelativeDistinguishedName_Clear(rdn); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PSetAttributeTypeAndValue.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PSetAttributeTypeAndValue.c new file mode 100644 index 000000000..01439e2e7 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PSetAttributeTypeAndValue.c @@ -0,0 +1,102 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_SetAttributeTypeAndValue + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRelativeDistinguishedName_SetAttributeTypeAndValue +( + NSSPKIXRelativeDistinguishedName *rdn, + PRInt32 i, + NSSPKIXAttributeTypeAndValue *atav +) +{ + NSSPKIXAttributeTypeAndValue *dup; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + PR_ASSERT((NSSPKIXAttributeTypeAndValue **)NULL != rdn->atavs); + if( (NSSPKIXAttributeTypeAndValue **)NULL == rdn->atavs ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + return PR_FAILURE; + } + + if( 0 == rdn->count ) { + nss_pkix_RelativeDistinguishedName_Count(rdn); + } + + if( (i < 0) || (i >= rdn->count) ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } + + dup = nssPKIXAttributeTypeAndValue_Duplicate(atav, rdn->arena); + if( (NSSPKIXAttributeTypeAndValue *)NULL == dup ) { + return PR_FAILURE; + } + + nssPKIXAttributeTypeAndValue_Destroy(rdn->atavs[i]); + rdn->atavs[i] = dup; + + return nss_pkix_RelativeDistinguishedName_Clear(rdn); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/PSetAttributeTypeAndValues.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/PSetAttributeTypeAndValues.c new file mode 100644 index 000000000..839839ea2 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/PSetAttributeTypeAndValues.c @@ -0,0 +1,166 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_SetAttributeTypeAndValues + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_ATAV + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRelativeDistinguishedName_SetAttributeTypeAndValues +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSPKIXAttributeTypeAndValue *atavs[], + PRInt32 countOpt +) +{ + NSSPKIXAttributeTypeAndValue **ip; + NSSPKIXAttributeTypeAndValue **newarray; + PRUint32 i; + nssArenaMark *mark; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } + + if( (NSSPKIXAttributeTypeAndValues **)NULL == atavs ) { + nss_SetError(NSS_ERROR_INVALID_POINTER); + return PR_FAILURE; + } + + { + PRUint32 i, count; + + if( 0 == countOpt ) { + for( i = 0; i < 0x80000000; i++ ) { + if( (NSSPKIXAttributeTypeAndValue *)NULL == atav[i] ) { + break; + } + } + +#ifdef PEDANTIC + if( 0x80000000 == i ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } +#endif /* PEDANTIC */ + + count = (PRUint32)i; + } else { + if( countOpt < 0 ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } + + count = (PRUint32)countOpt; + } + + for( i = 0; i < count; i++ ) { + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav[i]) ) { + return PR_FAILURE; + } + } + } +#endif /* NSSDEBUG */ + + if( 0 == countOpt ) { + for( i = 0; i < 0xffffffff; i++ ) { + if( (NSSPKIXAttributeTypeAndValue *)NULL == atavs[i] ) { + break; + } + } + +#ifdef PEDANTIC + if( 0xffffffff == 0 ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + reutrn PR_FAILURE; + } +#endif /* PEDANTIC */ + + countOpt = i; + } + + mark = nssArena_Mark(rdn->mark); + if( (nssArenaMark *)NULL == mark ) { + return PR_FAILURE; + } + + newarray = nss_ZNEWARRAY(rdn->arena, NSSPKIXAttributeTypeAndValue *, countOpt); + if( (NSSPKIXAttributeTypeAndValue **)NULL == newarray ) { + goto loser; + } + + for( i = 0; i < countOpt; i++ ) { + newarray[i] = nssPKIXAttributeTypeAndValue_Duplicate(atavs[i], rdn->arena); + if( (NSSPKIXAttributeTypeAndValue *)NULL == newarray[i] ) { + goto loser; + } + } + + for( i = 0; i < rdn->count; i++ ) { + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_Destroy(rdn->atavs[i]) ) { + goto loser; + } + } + + nss_ZFreeIf(rdn->atavs); + + rdn->count = countOpt; + rdn->atavs = newarray; + + (void)nss_pkix_RelativeDistinguishedName_Clear(rdn); + + return nssArena_Unmark(rdn->arena, mark); + + loser: + (void)nssArena_Release(a->arena, mark); + return PR_FAILURE; +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/RemoveAttributeTypeAndValue.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/RemoveAttributeTypeAndValue.c new file mode 100644 index 000000000..b9f1deb66 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/RemoveAttributeTypeAndValue.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 */ + +/* + * NSSPKIXRelativeDistinguishedName_RemoveAttributeTypeAndValue + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_AT_MINIMUM + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRelativeDistinguishedName_RemoveAttributeTypeAndValue +( + NSSPKIXRelativeDistinguishedName *rdn, + PRInt32 i +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_RemoveAttributeTypeAndValue(rdn, i); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/SetAttributeTypeAndValue.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/SetAttributeTypeAndValue.c new file mode 100644 index 000000000..fa2224a6b --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/SetAttributeTypeAndValue.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 */ + +/* + * NSSPKIXRelativeDistinguishedName_SetAttributeTypeAndValue + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRelativeDistinguishedName_SetAttributeTypeAndValue +( + NSSPKIXRelativeDistinguishedName *rdn, + PRInt32 i, + NSSPKIXAttributeTypeAndValue *atav +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_SetAttributeTypeAndValue(rdn, i, atav); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/SetAttributeTypeAndValues.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/SetAttributeTypeAndValues.c new file mode 100644 index 000000000..c6a8f0434 --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/SetAttributeTypeAndValues.c @@ -0,0 +1,113 @@ +/* + * 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 */ + +/* + * NSSPKIXRelativeDistinguishedName_SetAttributeTypeAndValues + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_INVALID_POINTER + * NSS_ERROR_INVALID_ATAV + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRelativeDistinguishedName_SetAttributeTypeAndValues +( + NSSPKIXRelativeDistinguishedName *rdn, + NSSPKIXAttributeTypeAndValue *atavs[], + PRInt32 countOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } + + if( (NSSPKIXAttributeTypeAndValue **)NULL == atavs ) { + nss_SetError(NSS_ERROR_INVALID_POINTER); + return PR_FAILURE; + } + + { + PRUint32 i, count; + + if( 0 == countOpt ) { + for( i = 0; i < 0x80000000; i++ ) { + if( (NSSPKIXAttributeTypeAndValue *)NULL == atavs[i] ) { + break; + } + } + +#ifdef PEDANTIC + if( 0x80000000 == i ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } +#endif /* PEDANTIC */ + + count = (PRUint32)i; + } else { + if( countOpt < 0 ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } + + count = (PRUint32)countOpt; + } + + for( i = 0; i < count; i++ ) { + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atavs[i]) ) { + return PR_FAILURE; + } + } + } +#endif /* DEBUG */ + + return nssPKIXRelativeDistinguishedName_SetAttributeTypeAndValues(rdn, atavs, countOpt); +} diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/template.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/template.c new file mode 100644 index 000000000..fff01836a --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/template.c @@ -0,0 +1,55 @@ +/* + * 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 */ + +/* + * nssPKIXRelativeDistinguishedName_template + * + */ + +const nssASN1Template nssPKIXRelativeDistinguishedName_template[] = { + { nssASN1_SET_OF, offsetof(NSSPKIXRelativeDistinguishedName, atavs), + nssPKIXAttributeTypeAndValue_template, + sizeof(NSSPKIXRelativeDistinguishedName) } +}; diff --git a/security/nss/lib/pkix/src/RelativeDistinguishedName/verifyPointer.c b/security/nss/lib/pkix/src/RelativeDistinguishedName/verifyPointer.c new file mode 100644 index 000000000..d7274abae --- /dev/null +++ b/security/nss/lib/pkix/src/RelativeDistinguishedName/verifyPointer.c @@ -0,0 +1,205 @@ +/* + * 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_rdn_pointer_tracker; + +/* + * nss_pkix_RelativeDistinguishedName_add_pointer + * + * This method is only present in debug builds. + * + * This module-private routine adds an NSSPKIXRelativeDistinguishedName 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_RelativeDistinguishedName_add_pointer +( + const NSSPKIXRelativeDistinguishedName *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_rdn_pointer_tracker); + if( PR_SUCCESS != rv ) { + return rv; + } + + rv = nssPointerTracker_add(&pkix_rdn_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_RelativeDistinguishedName_remove_pointer, p); + if( PR_SUCCESS != rv ) { + (void)nss_pkix_RelativeDistinguishedName_remove_pointer(p); + return rv; + } + +#ifdef NSSDEBUG + { + NSSPKIXAttributeTypeAndValue *a; + + for( a = p->atavs; *a; a++ ) { + if( PR_SUCCESS != nss_pkix_AttributeTypeAndValue_add_pointer(*a) ) { + nss_pkix_RelativeDistinguishedName_remove_pointer(p); + return PR_FAILURE; + } + } + } +#endif /* NSSDEBUG */ + + return PR_SUCCESS; +} + +/* + * nss_pkix_RelativeDistinguishedName_remove_pointer + * + * This method is only present in debug builds. + * + * This module-private routine removes a valid NSSPKIXRelativeDistinguishedName + * 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_RelativeDistinguishedName_remove_pointer +( + const NSSPKIXRelativeDistinguishedName *p +) +{ + PRStatus rv; + +#ifdef NSSDEBUG + { + NSSPKIXAttributeTypeAndValue *a; + + for( a = p->atavs; *a; a++ ) { + (void)nss_pkix_AttributeTypeAndValue_remove_pointer(*a); + } + } +#endif /* NSSDEBUG */ + + rv = nssPointerTracker_remove(&pkix_rdn_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + } + + /* + * nssArena_deregisterDestructor(p->arena, + * nss_pkix_RelativeDistinguishedName_remove_pointer, p); + */ + + return rv; +} + +/* + * nssPKIXRelativeDistinguishedName_verifyPointer + * + * This method is only present in debug builds. + * + * If the specified pointer is a valid pointer to an NSSPKIXRelativeDistinguishedName + * 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 +nssPKIXRelativeDistinguishedName_verifyPointer +( + NSSPKIXRelativeDistinguishedName *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_rdn_pointer_tracker); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + rv = nssPointerTracker_verify(&pkix_rdn_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + return PR_SUCCESS; +} + +#endif /* DEBUG */ + |