diff options
Diffstat (limited to 'security/nss/lib/pkix/src')
230 files changed, 22825 insertions, 0 deletions
diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/Create.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/Create.c new file mode 100644 index 000000000..cf95b4e26 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/Create.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 */ + +/* + * NSSPKIXAlgorithmIdentifier_Create + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_OID + * NSS_ERROR_INVALID_POINTER + * + * Return value: + * A valid pointer to an NSSPKIXAlgorithmIdentifier upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAlgorithmIdentifier * +NSSPKIXAlgorithmIdentifier_Create +( + NSSArena *arenaOpt, + NSSOID *algorithm, + NSSItem *parameters +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } + } + + if( PR_SUCCESS != nssOID_verifyPointer(algorithm) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } + + if( PR_SUCCESS != nssItem_verifyPointer(parameters) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXAlgorithmIdentifier_Create(arenaOpt, algorithm, parameters); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/Decode.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/Decode.c new file mode 100644 index 000000000..1e4e47b03 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/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 */ + +/* + * NSSPKIXAlgorithmIdentifier_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 NSSPKIXAlgorithmIdentifier upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAlgorithmIdentifier * +NSSPKIXAlgorithmIdentifier_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXAlgorithmIdentifier_Decode(arenaOpt, ber); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/Destroy.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/Destroy.c new file mode 100644 index 000000000..f2a901151 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/Destroy.c @@ -0,0 +1,71 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXAlgorithmIdentifier_Destroy + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAlgorithmIdentifier_Destroy +( + NSSPKIXAlgorithmIdentifier *algid +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAlgorithmIdentifier_Destroy(algid); +} + diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/Duplicate.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/Duplicate.c new file mode 100644 index 000000000..186ab49bc --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/Duplicate.c @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXAlgorithmIdentifier_Duplicate + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXAlgorithmIdentifier upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAlgorithmIdentifier * +NSSPKIXAlgorithmIdentifier_Duplicate +( + NSSPKIXAlgorithmIdentifier *algid, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAlgorithmIdentifier_Duplicate(algid, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/Encode.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/Encode.c new file mode 100644 index 000000000..d390b3595 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/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 */ + +/* + * NSSPKIXAlgorithmIdentifier_Encode + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +NSSPKIXAlgorithmIdentifier_Encode +( + NSSPKIXAlgorithmIdentifier *algid, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAlgorithmIdentifier_Encode(algid, encoding, rvOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/Equal.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/Equal.c new file mode 100644 index 000000000..65c52a2ba --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/Equal.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 */ + +/* + * NSSPKIXAlgorithmIdentifier_Equal + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +NSSPKIXAlgorithmIdentifier_Equal +( + NSSPKIXAlgorithmIdentifier *algid1, + NSSPKIXAlgorithmIdentifier *algid2, + PRStatus *statusOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } +#endif /* DEBUG */ + + return nssPKIXAlgorithmIdentifier_Equal(algid1, algid2, statusOpt); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/GetAlgorithm.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/GetAlgorithm.c new file mode 100644 index 000000000..be7493a66 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/GetAlgorithm.c @@ -0,0 +1,71 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXAlgorithmIdentifier_GetAlgorithm + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSOID pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSOID * +NSSPKIXAlgorithmIdentifier_GetAlgorithm +( + NSSPKIXAlgorithmIdentifier *algid +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return (NSSOID *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXAlgorithmIdentifier_GetAlgorithm(algid); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/GetParameters.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/GetParameters.c new file mode 100644 index 000000000..e94622e23 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/GetParameters.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 */ + +/* + * NSSPKIXAlgorithmIdentifier_GetParameters + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSItem upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSItem * +NSSPKIXAlgorithmIdentifier_GetParameters +( + NSSPKIXAlgorithmIdentifier *algid, + NSSItem *rvOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return (NSSItem *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSItem *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAlgorithmIdentifier_GetParameters(algid, rvOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/MClear.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/MClear.c new file mode 100644 index 000000000..0797fbd49 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/MClear.c @@ -0,0 +1,71 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIXM_H +#include "pkixm.h" +#endif /* PKIXM_H */ + +/* + * nss_pkix_AlgorithmIdentifier_Clear + * + * Wipes out cached data. + */ + +NSS_IMPLEMENT PRStatus +nss_pkix_AlgorithmIdentifier_Clear +( + NSSPKIXAlgorithmIdentifier *algid +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( (NSSBER *)NULL != algid->ber ) { + nss_ZFreeIf(algid->ber->data); + nss_ZFreeIf(algid->ber); + } + + if( (NSSDER *)NULL != algid->der ) { + nss_ZFreeIf(algid->der->data); + nss_ZFreeIf(algid->der); + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/PCreate.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/PCreate.c new file mode 100644 index 000000000..c527a6a56 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/PCreate.c @@ -0,0 +1,138 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXAlgorithmIdentifier_Create + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_OID + * NSS_ERROR_INVALID_POINTER + * + * Return value: + * A valid pointer to an NSSPKIXAlgorithmIdentifier upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAlgorithmIdentifier * +nssPKIXAlgorithmIdentifier_Create +( + NSSArena *arenaOpt, + NSSOID *algorithm, + NSSItem *parameters +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAlgorithmIdentifier *rv = (NSSPKIXAlgorithmIdentifier *)NULL; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } + } + + if( PR_SUCCESS != nssOID_verifyPointer(algorithm) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } + + if( PR_SUCCESS != nssItem_verifyPointer(parameters) ) { + return (NSSPKIXAlgorithmIdentifier *)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, NSSPKIXAlgorithmIdentifier); + if( (NSSPKIXAlgorithmIdentifier *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + rv->algorithm = algorithm; + rv->parameters = nssItem_Duplicate(parameters, arena, (NSSItem *)NULL); + if( (NSSItem *)NULL == rv->parameters ) { + goto loser; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_AlgorithmIdentifier_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 (NSSPKIXAlgorithmIdentifier *)NULL; +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/PDecode.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/PDecode.c new file mode 100644 index 000000000..9713d34db --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/PDecode.c @@ -0,0 +1,137 @@ +/* + * 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 */ + +/* + * nssPKIXAlgorithmIdentifier_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 NSSPKIXAlgorithmIdentifier upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAlgorithmIdentifier * +nssPKIXAlgorithmIdentifier_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAlgorithmIdentifier *rv = (NSSPKIXAlgorithmIdentifier *)NULL; + PRStatus status; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXAlgorithmIdentifier *)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, NSSPKIXAlgorithmIdentifier); + if( (NSSPKIXAlgorithmIdentifier *)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, nssPKIXAlgorithmIdentifier_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_AlgorithmIdentifier_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 (NSSPKIXAlgorithmIdentifier *)NULL; +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/PDestroy.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/PDestroy.c new file mode 100644 index 000000000..7ef4d1fe1 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/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 */ + +/* + * nssPKIXAlgorithmIdentifier_Destroy + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXAlgorithmIdentifier_Destroy +( + NSSPKIXAlgorithmIdentifier *algid +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + +#ifdef DEBUG + (void)nss_pkix_AlgorithmIdentifier_remove_pointer(algid); +#endif /* DEBUG */ + + if( PR_TRUE == algid->i_allocated_arena ) { + return nssArena_Destroy(algid->arena); + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/PDuplicate.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/PDuplicate.c new file mode 100644 index 000000000..ae3cf72b2 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/PDuplicate.c @@ -0,0 +1,144 @@ +/* + * 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 */ + +/* + * nssPKIXAlgorithmIdentifier_Duplicate + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXAlgorithmIdentifier upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAlgorithmIdentifier * +nssPKIXAlgorithmIdentifier_Duplicate +( + NSSPKIXAlgorithmIdentifier *algid, + NSSArena *arenaOpt +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAlgorithmIdentifier *rv = (NSSPKIXAlgorithmIdentifier *)NULL; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return (NSSPKIXAlgorithmIdentifier *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAlgorithmIdentifier *)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, NSSPKIXAlgorithmIdentifier); + if( (NSSPKIXAlgorithmIdentifier *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + + rv->ber = nssItem_Duplicate(algid->ber, arena, (NSSItem *)NULL); + if( (NSSItem *)NULL == rv->ber ) { + goto loser; + } + + rv->der = nssItem_Duplicate(algid->der, arena, (NSSItem *)NULL); + if( (NSSItem *)NULL == rv->der ) { + goto loser; + } + + rv->algorithm = algid->algorithm; + + rv->parameters = nssItem_Duplicate(algid->parameters, arena, (NSSItem *)NULL); + if( (NSSItem *)NULL == rv->parameters ) { + goto loser; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_AlgorithmIdentifier_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 (NSSPKIXAlgorithmIdentifier *)NULL; +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/PEncode.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/PEncode.c new file mode 100644 index 000000000..c9939350a --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/PEncode.c @@ -0,0 +1,117 @@ +/* + * 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 */ + +/* + * nssPKIXAlgorithmIdentifier_Encode + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +nssPKIXAlgorithmIdentifier_Encode +( + NSSPKIXAlgorithmIdentifier *algid, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + 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 != algid->ber ) { + it = algid->ber; + goto done; + } + /*FALLTHROUGH*/ + case NSSASN1DER: + if( (NSSDER *)NULL != algid->der ) { + it = algid->der; + goto done; + } + break; + default: + nss_SetError(NSS_ERROR_UNSUPPORTED_ENCODING); + return (NSSBER *)NULL; + } + + it = nssASN1_EncodeItem(algid->arena, (NSSItem *)NULL, algid, + nssPKIXAlgorithmIdentifier_template, encoding); + if( (NSSBER *)NULL == it ) { + return (NSSBER *)NULL; + } + + switch( encoding ) { + case NSSASN1BER: + algid->ber = it; + break; + case NSSASN1DER: + algid->der = it; + break; + default: + PR_ASSERT(0); + break; + } + + done: + return nssItem_Duplicate(it, arenaOpt, rvOpt); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/PEqual.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/PEqual.c new file mode 100644 index 000000000..423dfdb74 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/PEqual.c @@ -0,0 +1,88 @@ +/* + * 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 */ + +/* + * nssPKIXAlgorithmIdentifier_Equal + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +nssPKIXAlgorithmIdentifier_Equal +( + NSSPKIXAlgorithmIdentifier *algid1, + NSSPKIXAlgorithmIdentifier *algid2, + PRStatus *statusOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } +#endif /* NSSDEBUG */ + + if( algid1->algorithm != algid2->algorithm ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_SUCCESS; + } + return PR_FALSE; + } + + return nssItem_Equal(algid1->parameters, algid2->parameters, statusOpt); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/PGetAlgorithm.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/PGetAlgorithm.c new file mode 100644 index 000000000..4c7c37b6e --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/PGetAlgorithm.c @@ -0,0 +1,69 @@ +/* + * 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 */ + +/* + * nssPKIXAlgorithmIdentifier_GetAlgorithm + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSOID pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSOID * +nssPKIXAlgorithmIdentifier_GetAlgorithm +( + NSSPKIXAlgorithmIdentifier *algid +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return (NSSOID *)NULL; + } +#endif /* NSSDEBUG */ + + return algid->algorithm; +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/PGetParameters.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/PGetParameters.c new file mode 100644 index 000000000..5d6f1decb --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/PGetParameters.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 */ + +/* + * nssPKIXAlgorithmIdentifier_GetParameters + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSItem upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSItem * +nssPKIXAlgorithmIdentifier_GetParameters +( + NSSPKIXAlgorithmIdentifier *algid, + NSSItem *rvOpt, + NSSArena *arenaOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return (NSSItem *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSItem *)NULL; + } + } +#endif /* NSSDEBUG */ + + return nssItem_Duplicate(algid->parameters, arenaOpt, rvOpt); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/PSetAlgorithm.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/PSetAlgorithm.c new file mode 100644 index 000000000..ccf9f23e2 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/PSetAlgorithm.c @@ -0,0 +1,75 @@ +/* + * 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 */ + +/* + * nssPKIXAlgorithmIdentifier_SetAlgorithm + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_INVALID_OID + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXAlgorithmIdentifier_SetAlgorithm +( + NSSPKIXAlgorithmIdentifier *algid, + NSSOID *algorithm +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssOID_verifyPointer(algorithm) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + algid->algorithm = algorithm; + return nss_pkix_AlgorithmIdentifier_Clear(algid); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/PSetParameters.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/PSetParameters.c new file mode 100644 index 000000000..d5a7e8424 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/PSetParameters.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 */ + +/* + * nssPKIXAlgorithmIdentifier_SetParameters + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_INVALID_POINTER + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXAlgorithmIdentifier_SetParameters +( + NSSPKIXAlgorithmIdentifier *algid, + NSSItem *parameters +) +{ + NSSItem *prev; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssItem_verifyPointer(parameters) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + prev = algid->parameters; + + algid->parameters = nssItem_Duplicate(parameters, algid->arena, (NSSItem *)NULL); + if( (NSSItem *)NULL == algid->parameters ) { + algid->parameters = prev; + return PR_FAILURE; + } + + (void)nssItem_Destroy(prev); + return nss_pkix_AlgorithmIdentifier_Clear(algid); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/SetAlgorithm.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/SetAlgorithm.c new file mode 100644 index 000000000..d829643e0 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/SetAlgorithm.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 */ + +/* + * NSSPKIXAlgorithmIdentifier_SetAlgorithm + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_INVALID_OID + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAlgorithmIdentifier_SetAlgorithm +( + NSSPKIXAlgorithmIdentifier *algid, + NSSOID *algorithm +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssOID_verifyPointer(algorithm) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAlgorithmIdentifier_SetAlgorithm(algid, algorithm); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/SetParameters.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/SetParameters.c new file mode 100644 index 000000000..d751fb689 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/SetParameters.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 */ + +/* + * NSSPKIXAlgorithmIdentifier_SetParameters + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ALGORITHM_IDENTIFIER + * NSS_ERROR_INVALID_POINTER + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAlgorithmIdentifier_SetParameters +( + NSSPKIXAlgorithmIdentifier *algid, + NSSItem *parameters +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAlgorithmIdentifier_verifyPointer(algid) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssItem_verifyPointer(parameters) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAlgorithmIdentifier_SetParameters(algid, parameters); +} diff --git a/security/nss/lib/pkix/src/AlgorithmIdentifier/verifyPointer.c b/security/nss/lib/pkix/src/AlgorithmIdentifier/verifyPointer.c new file mode 100644 index 000000000..c9a9f8072 --- /dev/null +++ b/security/nss/lib/pkix/src/AlgorithmIdentifier/verifyPointer.c @@ -0,0 +1,182 @@ +/* + * 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_algid_pointer_tracker; + +/* + * nss_pkix_AlgorithmIdentifier_add_pointer + * + * This method is only present in debug builds. + * + * This module-private routine adds an NSSPKIXAlgorithmIdentifier 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_AlgorithmIdentifier_add_pointer +( + const NSSPKIXAlgorithmIdentifier *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_algid_pointer_tracker); + if( PR_SUCCESS != rv ) { + return rv; + } + + rv = nssPointerTracker_add(&pkix_algid_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_AlgorithmIdentifier_remove_pointer, p); + if( PR_SUCCESS != rv ) { + (void)nss_pkix_AlgorithmIdentifier_remove_pointer(p); + return rv; + } + + return rv; +} + +/* + * nss_pkix_AlgorithmIdentifier_remove_pointer + * + * This method is only present in debug builds. + * + * This module-private routine removes a valid NSSPKIXAlgorithmIdentifier + * 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_AlgorithmIdentifier_remove_pointer +( + const NSSPKIXAlgorithmIdentifier *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_remove(&pkix_algid_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + } + + /* + * nssArena_deregisterDestructor(p->arena, + * nss_pkix_AlgorithmIdentifier_remove_pointer, p); + */ + + return rv; +} + +/* + * nssPKIXAlgorithmIdentifier_verifyPointer + * + * This method is only present in debug builds. + * + * If the specified pointer is a valid pointer to an NSSPKIXAlgorithmIdentifier + * 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 +nssPKIXAlgorithmIdentifier_verifyPointer +( + NSSPKIXAlgorithmIdentifier *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_algid_pointer_tracker); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + rv = nssPointerTracker_verify(&pkix_algid_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + return PR_SUCCESS; +} + +#endif /* DEBUG */ + diff --git a/security/nss/lib/pkix/src/Attribute/AddValue.c b/security/nss/lib/pkix/src/Attribute/AddValue.c new file mode 100644 index 000000000..aad082c50 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/AddValue.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 */ + +/* + * NSSPKIXAttribute_AddValue + * + * This routine adds the specified attribute value to the set in + * the specified NSSPKIXAttribute. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_ITEM + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAttribute_AddValue +( + NSSPKIXAttribute *attribute, + NSSPKIXAttributeValue *value +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssItem_verifyPointer(value) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAttribute_AddValue(attribute, value); +} + diff --git a/security/nss/lib/pkix/src/Attribute/Create.c b/security/nss/lib/pkix/src/Attribute/Create.c new file mode 100644 index 000000000..9fe406b2d --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/Create.c @@ -0,0 +1,141 @@ +/* + * 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 */ + +/* + * NSSPKIXAttribute_Create + * + * This routine creates an NSSPKIXAttribute from specified components. + * This routine may return NULL upon error, in which case it will have + * created an error stack. If the optional arena argument is non-NULL, + * that arena will be used for the required memory. There must be at + * least one attribute value specified. The final argument must be + * NULL, to indicate the end of the set of attribute values. + * + * 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 + * NSS_ERROR_INSUFFICIENT_VALUES + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * A valid pointer to an NSSPKIXAttribute upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttribute * +NSSPKIXAttribute_Create +( + NSSArena *arenaOpt, + NSSPKIXAttributeType *typeOid, + NSSPKIXAttributeValue *value1, + ... +) +{ + va_list ap; + NSSPKIXAttribute *rv; + PRUint32 count; + + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } + + if( PR_SUCCESS != nssOID_verifyPointer(typeOid) ) { + return (NSSPKIXAttribute *)NULL; + } + + if( (NSSPKIXAttributeValue *)NULL == value1 ) { + nss_SetError(NSS_ERROR_INSUFFICIENT_VALUES); + return (NSSPKIXAttribute *)NULL; + } + + { + va_start(ap, typeOid); + + while( 1 ) { + NSSPKIXAttributeValue *v; + v = (NSSPKIXAttributeValue *)va_arg(ap, NSSPKIXAttributeValue *); + if( (NSSPKIXAttributeValue *)NULL == v ) { + break; + } + + if( PR_SUCCESS != nssItem_verifyPointer(v) ) { + va_end(ap); + return (NSSPKIXAttribute *)NULL; + } + } + + va_end(ap); + } +#endif /* DEBUG */ + + va_start(ap, typeOid); + + for( count = 0; ; count++ ) { + NSSPKIXAttributeValue *v; + v = (NSSPKIXAttributeValue *)va_arg(ap, NSSPKIXAttributeValue *); + if( (NSSPKIXAttributeValue *)NULL == v ) { + break; + } + +#ifdef PEDANTIC + if( count == 0xFFFFFFFF ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + va_end(ap); + return (NSSPKIXAttribute *)NULL; + } +#endif /* PEDANTIC */ + } + + va_end(ap); + + va_start(ap, typeOid); + rv = nss_pkix_Attribute_V_Create(arenaOpt, typeOid, count, ap); + va_end(ap); + + return rv; +} diff --git a/security/nss/lib/pkix/src/Attribute/CreateFromArray.c b/security/nss/lib/pkix/src/Attribute/CreateFromArray.c new file mode 100644 index 000000000..2928c3bcc --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/CreateFromArray.c @@ -0,0 +1,97 @@ +/* + * 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 */ + +/* + * NSSPKIXAttribute_CreateFromArray + * + * This routine creates an NSSPKIXAttribute from specified components. + * This routine may return NULL upon error, in which case it will have + * created an error stack. If the optional arena argument is non-NULL, + * that arena will be used for the required memory. There must be at + * least one attribute value specified. The final argument must be + * NULL, to indicate the end of the set of attribute values. + * + * 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 NSSPKIXAttribute upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttribute * +NSSPKIXAttribute_CreateFromArray +( + NSSArena *arenaOpt, + NSSPKIXAttributeType *typeOid, + PRUint32 count, + NSSPKIXAttributeValue values[] +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } + + if( PR_SUCCESS != nssOID_verifyPointer(typeOid) ) { + return (NSSPKIXAttribute *)NULL; + } + + { + PRUint32 i; + + for( i = 0; i < count; i++ ) { + if( PR_SUCCESS != nssItem_verifyPointer(&values[i]) ) { + return (NSSPKIXAttribute *)NULL; + } + } + } +#endif /* DEBUG */ + + return nssPKIXAttribute_CreateFromArray(arenaOpt, typeOid, count, values); +} diff --git a/security/nss/lib/pkix/src/Attribute/Decode.c b/security/nss/lib/pkix/src/Attribute/Decode.c new file mode 100644 index 000000000..a16f195cd --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/Decode.c @@ -0,0 +1,84 @@ +/* + * 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 */ + +/* + * NSSPKIXAttribute_Decode + * + * This routine creates an NSSPKIXAttribute by decoding a BER- + * or DER-encoded Attribute as defined in RFC 2459. This + * routine may return NULL upon error, in which case it will + * have created an error stack. If the optional arena argument + * is non-NULL, that arena will be used for the required memory. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_BER + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_ITEM + * + * Return value: + * A valid pointer to an NSSPKIXAttribute upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttribute * +NSSPKIXAttribute_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXAttribute *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXAttribute_Decode(arenaOpt, ber); +} diff --git a/security/nss/lib/pkix/src/Attribute/Destroy.c b/security/nss/lib/pkix/src/Attribute/Destroy.c new file mode 100644 index 000000000..bd9454fca --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/Destroy.c @@ -0,0 +1,74 @@ +/* + * 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 */ + +/* + * NSSPKIXAttribute_Destroy + * + * This routine destroys an NSSPKIXAttribute. It should be called on + * all such objects created without an arena. It does not need to be + * called for objects created with an arena, but it may be. This + * routine returns a PRStatus value. Upon error, it will create an + * error stack and return PR_FAILURE. + * + * The error value may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_EXTERN PRStatus +NSSPKIXAttribute_Destroy +( + NSSPKIXAttribute *attribute +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAttribute_Destroy(attribute); +} diff --git a/security/nss/lib/pkix/src/Attribute/Duplicate.c b/security/nss/lib/pkix/src/Attribute/Duplicate.c new file mode 100644 index 000000000..146a49610 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/Duplicate.c @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXAttribute_Duplicate + * + * This routine duplicates an NSSPKIXAttribute. {arenaOpt} + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXAttribute upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttribute * +NSSPKIXAttribute_Duplicate +( + NSSPKIXAttribute *attribute, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return (NSSPKIXAttribute *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAttribute_Duplicate(attribute, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Attribute/Encode.c b/security/nss/lib/pkix/src/Attribute/Encode.c new file mode 100644 index 000000000..179bd3d68 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/Encode.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 */ + +/* + * NSSPKIXAttribute_Encode + * + * This routine returns an ASN.1 encoding of the specified + * NSSPKIXAttribute. {usual rules about itemOpt and arenaOpt} + * This routine indicates an error (NSS_ERROR_INVALID_DATA) + * if there are no attribute values (i.e., the last one was removed). + * + * The error value may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_DATA + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +NSSPKIXAttribute_Encode +( + NSSPKIXAttribute *attribute, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAttribute_Encode(attribute, encoding, rvOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Attribute/Equal.c b/security/nss/lib/pkix/src/Attribute/Equal.c new file mode 100644 index 000000000..d91782aea --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/Equal.c @@ -0,0 +1,88 @@ +/* + * 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 */ + +/* + * NSSPKIXAttribute_Equal + * + * This routine compares two NSSPKIXAttribute's for equality. + * It returns PR_TRUE if they are equal, PR_FALSE otherwise. + * This routine also returns PR_FALSE upon error; if you're + * that worried about it, check for an error stack. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +NSSPKIXAttribute_Equal +( + NSSPKIXAttribute *one, + NSSPKIXAttribute *two, + PRStatus *statusOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(one) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(two) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; + } +#endif /* DEBUG */ + + return nssPKIXAttribute_Equal(one, two); +} diff --git a/security/nss/lib/pkix/src/Attribute/FindValue.c b/security/nss/lib/pkix/src/Attribute/FindValue.c new file mode 100644 index 000000000..ba725051f --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/FindValue.c @@ -0,0 +1,84 @@ +/* + * 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 */ + +/* + * NSSPKIXAttribute_FindValue + * + * This routine searches the set of attribute values in the specified + * NSSPKIXAttribute for the provided data. If an exact match is found, + * then that value's index is returned. If an exact match is not + * found, -1 is returned. If there is more than one exact match, one + * index will be returned. {notes about unorderdness of SET, etc} + * If the index may not be represented as an integer, an error is + * indicated. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_ITEM + * 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 +NSSPKIXAttribute_FindValue +( + NSSPKIXAttribute *attribute, + NSSPKIXAttributeValue *value +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssItem_verifyPointer(value) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAttribute_FindValue(attribute, value); +} diff --git a/security/nss/lib/pkix/src/Attribute/GetType.c b/security/nss/lib/pkix/src/Attribute/GetType.c new file mode 100644 index 000000000..0bae2b988 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/GetType.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 */ + +/* + * NSSPKIXAttribute_GetType + * + * This routine returns the attribute type oid of the specified + * NSSPKIXAttribute. + * + * The error value may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSPKIXAttributeType pointer upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttributeType * +NSSPKIXAttribute_GetType +( + NSSPKIXAttribute *attribute +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return (NSSPKIXAttributeType *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXAttribute_GetType(attribute); +} diff --git a/security/nss/lib/pkix/src/Attribute/GetValue.c b/security/nss/lib/pkix/src/Attribute/GetValue.c new file mode 100644 index 000000000..afce8d135 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/GetValue.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 */ + +/* + * NSSPKIXAttribute_GetValue + * + * This routine returns the i'th attribute value of the set of + * values in the specified NSSPKIXAttribute. Although the set + * is unordered, an arbitrary ordering will be maintained until + * the data in the attribute is changed. {usual comments about + * itemOpt and arenaOpt} + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXAttributeValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeValue * +NSSPKIXAttribute_GetValue +( + NSSPKIXAttribute *attribute, + PRInt32 i, + NSSPKIXAttributeValue *itemOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return (NSSPKIXAttributeValue *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeValue *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAttribute_GetValue(attribute, i, itemOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Attribute/GetValueCount.c b/security/nss/lib/pkix/src/Attribute/GetValueCount.c new file mode 100644 index 000000000..0cdc36b60 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/GetValueCount.c @@ -0,0 +1,75 @@ +/* + * 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 */ + +/* + * NSSPKIXAttribute_GetValueCount + * + * This routine returns the number of attribute values present in + * the specified NSSPKIXAttribute. This routine returns a PRInt32. + * Upon error, this routine returns -1. This routine indicates an + * error if the number of values cannot be expressed as a PRInt32. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * Nonnegative integer upon success + * -1 upon failure. + */ + +NSS_IMPLEMENT PRInt32 +NSSPKIXAttribute_GetValueCount +( + NSSPKIXAttribute *attribute +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return -1; + } +#endif /* DEBUG */ + + return nssPKIXAttribute_GetValueCount(attribute); +} + diff --git a/security/nss/lib/pkix/src/Attribute/GetValues.c b/security/nss/lib/pkix/src/Attribute/GetValues.c new file mode 100644 index 000000000..986af03d1 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/GetValues.c @@ -0,0 +1,88 @@ +/* + * 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 */ + +/* + * NSSPKIXAttribute_GetValues + * + * This routine returns all of the attribute values in the specified + * NSSPKIXAttribute. If the optional pointer to an array of NSSItems + * is non-null, then that array will be used and returned; otherwise, + * an array will be allocated and returned. If the limit is nonzero + * (which is must be if the specified array is nonnull), then an + * error is indicated if it is smaller than the value count. + * {arenaOpt} + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_ARRAY_TOO_SMALL + * + * Return value: + * A valid pointer to an array of NSSItem's upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttributeValue * +NSSPKIXAttribute_GetValues +( + NSSPKIXAttribute *attribute, + NSSPKIXAttributeValue rvOpt[], + PRInt32 limit, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return (NSSPKIXAttributeValue *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyOpt(attribute) ) { + return (NSSPKIXAttributeValue *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAttribute_GetValues(attribute, rvOpt, limit, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Attribute/MClear.c b/security/nss/lib/pkix/src/Attribute/MClear.c new file mode 100644 index 000000000..6fb77ba7d --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/MClear.c @@ -0,0 +1,71 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nss_pkix_Attribute_Clear + * + * Wipes out cached data. + */ + +NSS_IMPLEMENT PRStatus +nss_pkix_Attribute_Clear +( + NSSPKIXAttribute *a +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(a) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( (NSSBER *)NULL != a->ber ) { + nss_ZFreeIf(a->ber->data); + nss_ZFreeIf(a->ber); + } + + if( (NSSDER *)NULL != a->der ) { + nss_ZFreeIf(a->der->data); + nss_ZFreeIf(a->der); + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/Attribute/MCount.c b/security/nss/lib/pkix/src/Attribute/MCount.c new file mode 100644 index 000000000..abb0831cb --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/MCount.c @@ -0,0 +1,87 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIXM_H +#include "pkixm.h" +#endif /* PKIXM_H */ + +/* + * nss_pkix_Attribute_Count + * + * This module-private routine sets the valuesCount part of the + * NSSPKIXAttribute argument. It does no checking, and is intended + * only for use inside the NSSPKIXAttribute implementation itself. + * There is no error return. There is no return value. + */ + +NSS_IMPLEMENT void +nss_pkix_Attribute_Count +( + NSSPKIXAttribute *a +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(a) ) { + return; + } +#endif /* NSSDEBUG */ + + PR_ASSERT((nssASN1Item **)NULL != a->asn1values); + if( (nssASN1Item *)NULL == a->asn1values ) { + nss_SetError(NSS_ERROR_ASSERTION_FAILED); + return; + } + + if( 0 == a->valuesCount ) { + PRUint32 i; + for( i = 0; i < 0xFFFFFFFF; i++ ) { + if( (nssASN1Item *)NULL == a->asn1values[i] ) { + break; + } + } + +#ifdef PEDANTIC + if( 0xFFFFFFFF == i ) { + return; + } +#endif /* PEDANTIC */ + + a->valuesCount = i; + } + + return; +} diff --git a/security/nss/lib/pkix/src/Attribute/MVCreate.c b/security/nss/lib/pkix/src/Attribute/MVCreate.c new file mode 100644 index 000000000..1a54026d4 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/MVCreate.c @@ -0,0 +1,165 @@ +/* + * 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_Attribute_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 + * NSS_ERROR_INTERNAL_ERROR; + * + * Return value: + * A valid pointer to an NSSPKIXAttribute upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttribute * +nss_pkix_Attribute_V_Create +( + NSSArena *arenaOpt, + NSSPKIXAttributeType *typeOid, + PRUint32 count, + va_list ap +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAttribute *rv = (NSSPKIXAttribute *)NULL; + PRStatus status; + PRUint32 i; + + 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, NSSPKIXAttribute); + if( (NSSPKIXAttribute *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + + rv->type = typeOid; + { + NSSItem typeder; + NSSItem *x = nssOID_GetDEREncoding(rv->type, &typeder, arena); + if( (NSSItem *)NULL == x ) { + goto loser; + } + + rv->asn1type.size = typeder.size; + rv->asn1type.data = typeder.data; + } + + rv->valuesCount = count; + + rv->asn1values = nss_ZNEWARRAY(arena, nssASN1Item *, count); + if( (nssASN1Item **)NULL == rv->asn1values ) { + goto loser; + } + + for( i = 0; i < count; i++ ) { + NSSItem tmp; + NSSPKIXAttributeValue *v = (NSSPKIXAttributeValue *) + va_arg(ap, NSSPKIXAttributeValue *); + + rv->asn1values[i] = nss_ZNEW(arena, nssASN1Item); + if( (nssASN1Item *)NULL == rv->asn1values[i] ) { + goto loser; + } + + if( (NSSItem *)NULL == nssItem_Duplicate(v, arena, &tmp) ) { + goto loser; + } + + rv->asn1values[i].size = tmp.size; + rv->asn1values[i].data = tmp.data; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_Attribute_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != + nssArena_registerDestructor(arena, + nss_pkix_Attribute_remove_pointer, + rv) ) { + (void)nss_pkix_Attribute_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 (NSSPKIXAttribute *)NULL; +} diff --git a/security/nss/lib/pkix/src/Attribute/PAddValue.c b/security/nss/lib/pkix/src/Attribute/PAddValue.c new file mode 100644 index 000000000..732845490 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PAddValue.c @@ -0,0 +1,140 @@ +/* + * 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 */ + +/* + * nssPKIXAttribute_AddValue + * + * This routine adds the specified attribute value to the set in + * the specified NSSPKIXAttribute. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_ITEM + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXAttribute_AddValue +( + NSSPKIXAttribute *a, + NSSPKIXAttributeValue *value +) +{ + PRUint32 newcount; + nssASN1Item **new_asn1_items = (nssASN1Item **)NULL; + NSSItem tmp; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(a) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssItem_verifyPointer(value) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + PR_ASSERT((nssASN1Item **)NULL != a->asn1values); + if( (nssASN1Item **)NULL == a->asn1values ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + return PR_FAILURE; + } + + if( 0 == a->valuesCount ) { + PRUint32 i; + + for( i = 0; i < 0xFFFFFFFF; i++ ) { + if( (nssASN1Item *)NULL == a->asn1values[i] ) { + break; + } + } + +#ifdef PEDANTIC + if( 0xFFFFFFFF == i ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + /* Internal error is that we don't handle them this big */ + return PR_FAILURE; + } +#endif /* PEDANTIC */ + + a->valuesCount = i; + } + + newcount = a->valuesCount + 1; + /* Check newcount for a rollover. */ + + /* Remember that our asn1values array is NULL-terminated */ + new_asn1_items = (nssASN1Item **)nss_ZRealloc(a->asn1values, + ((newcount+1) * sizeof(nssASN1Item *))); + if( (nssASN1Item **)NULL == new_asn1_items ) { + goto loser; + } + + new_asn1_items[ a->valuesCount ] = nss_ZNEW(a->arena, nssASN1Item); + if( (nssASN1Item *)NULL == new_asn1_items[ a->valuesCount ] ) { + goto loser; + } + + if( (NSSItem *)NULL == nssItem_Duplicate(value, a->arena, &tmp) ) { + goto loser; + } + + new_asn1_items[ a->valuesCount ]->size = tmp.size; + new_asn1_items[ a->valuesCount ]->data = tmp.data; + + a->valuesCount++; + a->asn1values = new_asn1_items; + + return nss_pkix_Attribute_Clear(a); + + loser: + if( (nssASN1Item **)NULL != new_asn1_items ) { + nss_ZFreeIf(new_asn1_items[ newcount-1 ]); + /* We could realloc back down, but we actually know it's a no-op */ + a->asn1values = new_asn1_items; + } + + return PR_FAILURE; +} diff --git a/security/nss/lib/pkix/src/Attribute/PCreate.c b/security/nss/lib/pkix/src/Attribute/PCreate.c new file mode 100644 index 000000000..40dc5c07c --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PCreate.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 */ + +/* + * nssPKIXAttribute_Create + * + * This routine creates an NSSPKIXAttribute from specified components. + * This routine may return NULL upon error, in which case it will have + * created an error stack. If the optional arena argument is non-NULL, + * that arena will be used for the required memory. There must be at + * least one attribute value specified. The final argument must be + * NULL, to indicate the end of the set of attribute values. + * + * 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 + * NSS_ERROR_INSUFFICIENT_VALUES + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * A valid pointer to an NSSPKIXAttribute upon success + * NULL upon failure. + */ + +NSS_EXTERN NSSPKIXAttribute * +nssPKIXAttribute_Create +( + NSSArena *arenaOpt, + NSSPKIXAttributeType *typeOid, + NSSPKIXAttributeValue *value1, + ... +) +{ + va_list ap; + NSSPKIXAttribute *rv; + PRUint32 count; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } + + if( PR_SUCCESS != nssOID_verifyPointer(typeOid) ) { + return (NSSPKIXAttribute *)NULL; + } + + if( (NSSPKIXAttributeValue *)NULL == value1 ) { + nss_SetError(NSS_ERROR_INSUFFICIENT_VALUES); + return (NSSPKIXAttribute *)NULL; + } + + { + va_start(ap, typeOid); + + while( 1 ) { + NSSPKIXAttributeValue *v; + v = (NSSPKIXAttributeValue *)va_arg(ap, NSSPKIXAttributeValue *); + if( (NSSPKIXAttributeValue *)NULL == v ) { + break; + } + + if( PR_SUCCESS != nssItem_verifyPointer(v) ) { + va_end(ap); + return (NSSPKIXAttribute *)NULL; + } + } + + va_end(ap); + } +#endif /* NSSDEBUG */ + + va_start(ap, typeOid); + + for( count = 0; ; count++ ) { + NSSPKIXAttributeValue *v; + v = (NSSPKIXAttributeValue *)va_arg(ap, NSSPKIXAttributeValue *); + if( (NSSPKIXAttributeValue *)NULL == v ) { + break; + } + +#ifdef PEDANTIC + if( count == 0xFFFFFFFF ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + va_end(ap); + return (NSSPKIXAttribute *)NULL; + } +#endif /* PEDANTIC */ + } + + va_end(ap); + + va_start(ap, typeOid); + rv = nss_pkix_Attribute_V_Create(arenaOpt, typeOid, count, ap); + va_end(ap); + + return rv; +} diff --git a/security/nss/lib/pkix/src/Attribute/PCreateFromArray.c b/security/nss/lib/pkix/src/Attribute/PCreateFromArray.c new file mode 100644 index 000000000..c2d301d12 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PCreateFromArray.c @@ -0,0 +1,191 @@ +/* + * 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 */ + +/* + * nssPKIXAttribute_CreateFromArray + * + * This routine creates an NSSPKIXAttribute from specified components. + * This routine may return NULL upon error, in which case it will have + * created an error stack. If the optional arena argument is non-NULL, + * that arena will be used for the required memory. There must be at + * least one attribute value specified. The final argument must be + * NULL, to indicate the end of the set of attribute values. + * + * 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 NSSPKIXAttribute upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttribute * +nssPKIXAttribute_CreateFromArray +( + NSSArena *arenaOpt, + NSSPKIXAttributeType *typeOid, + PRUint32 count, + NSSPKIXAttributeValue values[] +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAttribute *rv = (NSSPKIXAttribute *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } + + if( PR_SUCCESS != nssOID_verifyPointer(typeOid) ) { + return (NSSPKIXAttribute *)NULL; + } + + for( i = 0; i < count; i++ ) { + if( PR_SUCCESS != nssItem_verifyPointer(&values[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, NSSPKIXAttribute); + if( (NSSPKIXAttribute *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + + rv->type = typeOid; + { + NSSItem typeder; + NSSItem *x = nssOID_GetDEREncoding(rv->type, &typeder, arena); + if( (NSSItem *)NULL == x ) { + goto loser; + } + + rv->asn1type.size = typeder.size; + rv->asn1type.data = typeder.data; + } + + rv->valuesCount = count; + + rv->asn1values = nss_ZNEWARRAY(arena, nssASN1Item *, count); + if( (nssASN1Item **)NULL == rv->asn1values ) { + goto loser; + } + + for( i = 0; i < count; i++ ) { + NSSItem tmp; + NSSPKIXAttributeValue *v = &values[i]; + + rv->asn1values[i] = nss_ZNEW(arena, nssASN1Item); + if( (nssASN1Item *)NULL == rv->asn1values[i] ) { + goto loser; + } + + if( (NSSItem *)NULL == nssItem_Duplicate(v, arena, &tmp) ) { + goto loser; + } + + rv->asn1values[i].size = tmp.size; + rv->asn1values[i].data = tmp.data; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_Attribute_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != + nssArena_registerDestructor(arena, + nss_pkix_Attribute_remove_pointer, + rv) ) { + (void)nss_pkix_Attribute_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 (NSSPKIXAttribute *)NULL; +} diff --git a/security/nss/lib/pkix/src/Attribute/PDecode.c b/security/nss/lib/pkix/src/Attribute/PDecode.c new file mode 100644 index 000000000..49a059404 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PDecode.c @@ -0,0 +1,153 @@ +/* + * 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 */ + +/* + * nssPKIXAttribute_Decode + * + * This routine creates an NSSPKIXAttribute by decoding a BER- + * or DER-encoded Attribute as defined in RFC 2459. This + * routine may return NULL upon error, in which case it will + * have created an error stack. If the optional arena argument + * is non-NULL, that arena will be used for the required memory. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_BER + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_ITEM + * + * Return value: + * A valid pointer to an NSSPKIXAttribute upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttribute * +nssPKIXAttribute_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAttribute *rv = (NSSPKIXAttribute *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + 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, NSSPKIXAttribute); + if( (NSSPKIXAttribute *)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, nssPKIXAttribute_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_Attribute_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != nssArena_registerDestructor(arena, + nss_pkix_Attribute_remove_pointer, rv) ) { + (void)nss_pkix_Attribute_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 (NSSPKIXAttribute *)NULL; +} diff --git a/security/nss/lib/pkix/src/Attribute/PDestroy.c b/security/nss/lib/pkix/src/Attribute/PDestroy.c new file mode 100644 index 000000000..5f2b5a135 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PDestroy.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 PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXAttribute_Destroy + * + * This routine destroys an NSSPKIXAttribute. It should be called on + * all such objects created without an arena. It does not need to be + * called for objects created with an arena, but it may be. This + * routine returns a PRStatus value. Upon error, it place an error on + * the error stack and return PR_FAILURE. + * + * The error value may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXAttribute_Destroy +( + NSSPKIXAttribute *attribute +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + +#ifdef DEBUG + (void)nss_pkix_Attribute_remove_pointer(attribute); + (void)nssArena_RemoveDestructor(arena, nss_pkix_Attribute_remove_pointer, + attribute); +#endif /* DEBUG */ + + if( PR_TRUE == attribute->i_allocated_arena ) { + return nssArena_Destroy(attribute->arena); + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/Attribute/PDuplicate.c b/security/nss/lib/pkix/src/Attribute/PDuplicate.c new file mode 100644 index 000000000..765510e59 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PDuplicate.c @@ -0,0 +1,189 @@ +/* + * 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 */ + +/* + * nssPKIXAttribute_Duplicate + * + * This routine duplicates an NSSPKIXAttribute. {arenaOpt} + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXAttribute upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttribute * +nssPKIXAttribute_Duplicate +( + NSSPKIXAttribute *attribute, + NSSArena *arenaOpt +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAttribute *rv = (NSSPKIXAttribute *)NULL; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return PR_FAILURE; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return PR_FAILURE; + } + } +#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, NSSPKIXAttribute); + if( (NSSPKIXAttribute *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + + if( (NSSBER *)NULL != attribute->ber ) { + rv->ber = nssItem_Duplicate(arena, attribute->ber, (NSSItem *)NULL); + if( (NSSBER *)NULL == rv->ber ) { + goto loser; + } + } + + if( (NSSDER *)NULL != attribute->der ) { + rv->der = nssItem_Duplicate(arena, attribute->der, (NSSItem *)NULL); + if( (NSSDER *)NULL == rv->der ) { + goto loser; + } + } + + if( (void *)NULL != attribute->asn1type.data ) { + rv->asn1type.size = attribute->asn1type.size; + rv->asn1type.data = nss_ZAlloc(arena, attribute->asn1type.size); + if( (void *)NULL == rv->asn1type.data ) { + goto loser; + } + (void)nsslibc_memcpy(rv->asn1type.data, attribute->asn1type.data, + rv->asn1type.size); + } + + if( (nssASN1Item **)NULL != attribute->asn1values ) { + rv->asn1values = nss_ZNEWARRAY(arena, nssASN1Item *, attribute->valuesCount); + if( (nssASN1Item **)NULL == rv->asn1values ) { + goto loser; + } + + for( i = 0; i < attribute->valuesCount; i++ ) { + nssASN1Item *src; + nssASN1Item *dst; + + src = attribute->asn1values[i]; + dst = nss_ZNEW(arena, nssASN1Item); + if( (nssASN1Item *)NULL == dst ) { + goto loser; + } + + rv->asn1values[i] = dst; + + dst->size = src->size; + dst->data = nss_ZAlloc(arena, dst->size); + if( (void *)NULL == dst->data ) { + goto loser; + } + (void)nsslibc_memcpy(dst->data, src->data, src->size); + } + } + + rv->type = attribute->type; /* NULL or otherwise */ + rv->valuescount = attribute->valuesCount; + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_Attribute_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != + nssArena_registerDestructor(arena, + nss_pkix_Attribute_remove_pointer, + rv) ) { + (void)nss_pkix_Attribute_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 (NSSPKIXAttribute *)NULL; +} diff --git a/security/nss/lib/pkix/src/Attribute/PEncode.c b/security/nss/lib/pkix/src/Attribute/PEncode.c new file mode 100644 index 000000000..7fc647ed2 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PEncode.c @@ -0,0 +1,126 @@ +/* + * 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 */ + +/* + * nssPKIXAttribute_Encode + * + * This routine returns an ASN.1 encoding of the specified + * NSSPKIXAttribute. {usual rules about itemOpt and arenaOpt} + * This routine indicates an error (NSS_ERROR_INVALID_DATA) + * if there are no attribute values (i.e., the last one was removed). + * + * The error value may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_DATA + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +nssPKIXAttribute_Encode +( + NSSPKIXAttribute *a, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + NSSBER *it; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(a) ) { + 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 != a->ber ) { + it = a->ber; + goto done; + } + /*FALLTHROUGH*/ + case NSSASN1DER: + if( (NSSDER *)NULL != a->der ) { + it = a->der; + goto done; + } + break; + default: + nss_SetError(NSS_ERROR_UNSUPPORTED_ENCODING); + return (NSSBER *)NULL; + } + + it = nssASN1_EncodeItem(a->arena, (NSSItem *)NULL, a, + nssPKIXAttribute_template, encoding); + if( (NSSBER *)NULL == it ) { + return (NSSBER *)NULL; + } + + switch( encoding ) { + case NSSASN1BER: + a->ber = it; + break; + case NSSASN1DER: + a->der = it; + break; + default: + PR_ASSERT(0); + break; + } + + done: + return nssItem_Duplicate(it, arenaOpt, rvOpt); +} diff --git a/security/nss/lib/pkix/src/Attribute/PEqual.c b/security/nss/lib/pkix/src/Attribute/PEqual.c new file mode 100644 index 000000000..247bfd575 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PEqual.c @@ -0,0 +1,164 @@ +/* + * 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 */ + +/* + * nssPKIXAttribute_Equal + * + * This routine compares two NSSPKIXAttribute's for equality. + * It returns PR_TRUE if they are equal, PR_FALSE otherwise. + * This routine also returns PR_FALSE upon error; if you're + * that worried about it, check for an error stack. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +nssPKIXAttribute_Equal +( + NSSPKIXAttribute *one, + NSSPKIXAttribute *two, + PRStatus *statusOpt +) +{ + PRStatus dummyStatus = PR_SUCCESS; /* quiet warnings */ + PRStatus *status; + PRUint32 i; + + if( (PRStatus *)NULL != statusOpt ) { + status = statusOpt; + *status = PR_SUCCESS; + } else { + status = &dummyStatus; + } + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(one) ) { + *status = PR_FAILURE; + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(two) ) { + *status = PR_FAILURE; + return PR_FALSE; + } +#endif /* NSSDEBUG */ + + if( ((NSSDER *)NULL != one->der) && ((NSSDER *)NULL != two->der) ) { + return nssItem_Equal(one->der, two->der, statusOpt); + } + + if( (NSSPKIXAttributeType *)NULL == one->type ) { + NSSItem berOid; + berOid.size = one->asn1type.size; + berOid.data = one->asn1type.data; + one->type = (NSSPKIXAttributeType *)NSSOID_CreateFromBER(&berOid); + } + + if( (NSSPKIXAttributeType *)NULL == two->type ) { + NSSItem berOid; + berOid.size = two->asn1type.size; + berOid.data = two->asn1type.data; + two->type = (NSSPKIXAttributeType *)NSSOID_CreateFromBER(&berOid); + } + + if( one->type != two->type ) { + return PR_FALSE; + } + + if( 0 == one->valuesCount ) { + nss_pkix_Attribute_Count(one); + } + +#ifdef PEDANTIC + if( 0 == one->valuesCount ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + *statusOpt = PR_FAILURE; + return PR_FALSE; + } +#endif /* PEDANTIC */ + + if( 0 == two->valuesCount ) { + nss_pkix_Attribute_Count(two); + } + +#ifdef PEDANTIC + if( 0 == two->valuesCount ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + *statusOpt = PR_FAILURE; + return PR_FALSE; + } +#endif /* PEDANTIC */ + + if( one->valuesCount != two->valuesCount ) { + return PR_FALSE; + } + + *status = nss_pkix_Attribute_Distinguish(one); + if( PR_FAILURE == *status ) { + return PR_FALSE; + } + + *status = nss_pkix_Attribute_Distinguish(two); + if( PR_FAILURE == *status ) { + return PR_FALSE; + } + + for( i == 0; i < one->valuesCount; i++ ) { + NSSItem onetmp, twotmp; + + onetmp.size = one->asn1values[i]->size; + onetmp.data = one->asn1values[i]->data; + twotmp.size = two->asn1values[i]->size; + twotmp.data = two->asn1values[i]->data; + + if( PR_FALSE == nssItem_Equal(&one, &two, statusOpt) ) { + return PR_FALSE; + } + } + + return PR_TRUE; +} diff --git a/security/nss/lib/pkix/src/Attribute/PFindValue.c b/security/nss/lib/pkix/src/Attribute/PFindValue.c new file mode 100644 index 000000000..0f1095f0c --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PFindValue.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 */ + +/* + * nssPKIXAttribute_FindValue + * + * This routine searches the set of attribute values in the specified + * NSSPKIXAttribute for the provided data. If an exact match is found, + * then that value's index is returned. If an exact match is not + * found, -1 is returned. If there is more than one exact match, one + * index will be returned. {notes about unorderdness of SET, etc} + * If the index may not be represented as an integer, an error is + * indicated. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_ITEM + * 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 +nssPKIXAttribute_FindValue +( + NSSPKIXAttribute *a, + NSSPKIXAttributeValue *attributeValue +) +{ + PRUint32 i; + nssASN1Item **a; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(a) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssItem_verifyPointer(value) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + PR_ASSERT((nssASN1Item **)NULL != a->asn1values); + if( (nssASN1Item **)NULL == a->asn1values ) { + nss_SetError(NSS_ERROR_ASSERTION_FAILED); + return -1; + } + + for( i = 0, a = &a->asn1values[0]; *a; a++, (i > 0x7fffffff) || i++ ) { + NSSItem tmp; + + tmp.size = (*a)->size; + tmp.data = (*a)->data; + + if( PR_TRUE == nssItem_Equal(attributeValue, &tmp, (PRStatus *)NULL) ) { + 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/Attribute/PGetType.c b/security/nss/lib/pkix/src/Attribute/PGetType.c new file mode 100644 index 000000000..4b61431b8 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PGetType.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 */ + +/* + * nssPKIXAttribute_GetType + * + * This routine returns the attribute type oid of the specified + * NSSPKIXAttribute. + * + * The error value may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSPKIXAttributeType pointer upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttributeType * +nssPKIXAttribute_GetType +( + NSSPKIXAttribute *a +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(a) ) { + return (NSSPKIXAttributeType *)NULL; + } +#endif /* NSSDEBUG */ + + if( (NSSPKIXAttributeType *)NULL == a->type ) { + NSSItem ber; + + ber.size = a->asn1type.size; + ber.data = a->asn1type.data; + + a->type = (NSSPKIXAttributeType *)NSSOID_CreateFromBER(&ber); + } + + return a->type; +} diff --git a/security/nss/lib/pkix/src/Attribute/PGetValue.c b/security/nss/lib/pkix/src/Attribute/PGetValue.c new file mode 100644 index 000000000..bbf12ca67 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PGetValue.c @@ -0,0 +1,98 @@ +/* + * 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 */ + +/* + * nssPKIXAttribute_GetValue + * + * This routine returns the i'th attribute value of the set of + * values in the specified NSSPKIXAttribute. Although the set + * is unordered, an arbitrary ordering will be maintained until + * the data in the attribute is changed. {usual comments about + * itemOpt and arenaOpt} [0,valueCount) + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXAttributeValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeValue * +nssPKIXAttribute_GetValue +( + NSSPKIXAttribute *attribute, + PRInt32 i, + NSSPKIXAttributeValue *itemOpt, + NSSArena *arenaOpt +) +{ + NSSItem tmp; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return (NSSPKIXAttributeValue *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeValue *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( 0 == attribute->valuesCount ) { + nss_pkix_Attribute_Count(attribute); + } + + if( (i < 0) || (i >= attribute->valuesCount) ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXAttributeValue *)NULL; + } + + tmp.size = attribute->asn1values[i]->size; + tmp.data = attribute->asn1values[i]->data; + + return nssItem_Duplicate(&tmp, arenaOpt, itemOpt); +} diff --git a/security/nss/lib/pkix/src/Attribute/PGetValueCount.c b/security/nss/lib/pkix/src/Attribute/PGetValueCount.c new file mode 100644 index 000000000..ada1d403d --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PGetValueCount.c @@ -0,0 +1,88 @@ +/* + * 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 */ + +/* + * nssPKIXAttribute_GetValueCount + * + * This routine returns the number of attribute values present in + * the specified NSSPKIXAttribute. This routine returns a PRInt32. + * Upon error, this routine returns -1. This routine indicates an + * error if the number of values cannot be expressed as a PRInt32. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * Nonnegative integer upon success + * -1 upon failure. + */ + +NSS_IMPLEMENT PRInt32 +nssPKIXAttribute_GetValueCount +( + NSSPKIXAttribute *attribute +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return -1; + } +#endif /* NSSDEBUG */ + + if( 0 == attribute->valuesCount ) { + nss_pkix_Attribute_Count(attribute); + } + +#ifdef PEDANTIC + if( 0 == attribute->valuesCount ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return -1; + } +#endif /* PEDANTIC */ + + if( attribute->valuesCount > 0x7fffffff ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return -1; + } + + return (PRInt32)(attribute->valuesCount); +} diff --git a/security/nss/lib/pkix/src/Attribute/PGetValues.c b/security/nss/lib/pkix/src/Attribute/PGetValues.c new file mode 100644 index 000000000..ccc11dbe0 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PGetValues.c @@ -0,0 +1,145 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXAttribute_GetValues + * + * This routine returns all of the attribute values in the specified + * NSSPKIXAttribute. If the optional pointer to an array of NSSItems + * is non-null, then that array will be used and returned; otherwise, + * an array will be allocated and returned. If the limit is nonzero + * (which is must be if the specified array is nonnull), then an + * error is indicated if it is smaller than the value count. + * {arenaOpt} + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_ARRAY_TOO_SMALL + * + * Return value: + * A valid pointer to an array of NSSItem's upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXAttributeValue * +nssPKIXAttribute_GetValues +( + NSSPKIXAttribute *attribute, + NSSPKIXAttributeValue rvOpt[], + PRInt32 limit, + NSSArena *arenaOpt +) +{ + NSSPKIXAttributeValue *rv = (NSSPKIXAttributeValue *)NULL; + PRUint32 i; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return (NSSPKIXAttributeValue *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyOpt(attribute) ) { + return (NSSPKIXAttributeValue *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( 0 == attribute->valuesCount ) { + nss_pkix_Attribute_Count(attribute); + } + +#ifdef PEDANTIC + if( 0 == attribute->valuesCount ) { + if( 0 == limit ) { + nss_SetError(NSS_ERROR_NO_MEMORY); + } else { + nss_SetError(NSS_ERROR_ARRAY_TOO_SMALL); + } + return (NSSPKIXAttributeValue *)NULL; + } +#endif /* PEDANTIC */ + + if( (limit < attribute->valuesCount) && + !((0 == limit) && ((NSSPKIXAttributeValue *)NULL == rvOpt)) ) { + nss_SetError(NSS_ERROR_ARRAY_TOO_SMALL); + return (NSSPKIXAttributeValue *)NULL; + } + + limit = attribute->valuesCount; + if( (NSSPKIXAttributeValue *)NULL == rvOpt ) { + rv = nss_ZNEWARRAY(arenaOpt, NSSPKIXAttributeValue, limit); + if( (NSSPKIXAttributeValue *)NULL == rv ) { + return (NSSPKIXAttributeValue *)NULL; + } + } else { + rv = rvOpt; + } + + for( i = 0; i < limit; i++ ) { + NSSAttributeValue tmp; + nssASN1Item *p = attribute->asn1values[i]; + NSSAttributeValue *r = &rv[i]; + + tmp.size = p->size; + tmp.data = p->data; + + if( (NSSItem *)NULL == nssItem_Duplicate(&tmp, arenaOpt, r) ) { + goto loser; + } + } + + return rv; + + loser: + for( i = 0; i < limit; i++ ) { + NSSAttributeValue *r = &rv[i]; + nss_ZFreeIf(r->data); + } + + if( rv != rvOpt ) { + nss_ZFreeIf(rv); + } + + return (NSSAttributeValue *)NULL; +} diff --git a/security/nss/lib/pkix/src/Attribute/PRemoveValue.c b/security/nss/lib/pkix/src/Attribute/PRemoveValue.c new file mode 100644 index 000000000..6da2ebc07 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PRemoveValue.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 */ + +/* + * nssPKIXAttribute_RemoveValue + * + * This routine removes the i'th attribute value of the set in the + * specified NSSPKIXAttribute. An attempt to remove the last value + * will fail. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_AT_MINIMUM + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +PR_IMPLEMENET(PRStatus) +nssPKIXAttribute_RemoveValue +( + NSSPKIXAttribute *a, + PRInt32 i +) +{ + nssASN1Item **ip; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(a) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( 0 == a->valuesCount ) { + nss_pkix_Attribute_Count(a); + } + + if( i < 0 ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } + + if( 1 == a->valuesCount ) { + nss_SetError(NSS_ERROR_AT_MINIMUM); + return PR_FAILURE; + } + +#ifdef PEDANTIC + if( 0 == a->valuesCount ) { + /* Too big.. but we can still remove one */ + nss_ZFreeIf(a->asn1values[i].data); + for( ip = &a->asn1values[i]; *ip; ip++ ) { + ip[0] = ip[1]; + } + } else +#endif /* PEDANTIC */ + + { + nssASN1Item *si; + PRUint32 end; + + if( i >= a->valueCount ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } + + end = a->valuesCount - 1; + + si = a->asn1values[i]; + a->asn1values[i] = a->asn1values[ end ]; + a->asn1values[ end ] = (nssASN1Item *)NULL; + + nss_ZFreeIf(si->data); + nss_ZFreeIf(si); + + /* We could realloc down, but we know it's a no-op */ + a->valuesCount = end; + } + + return nss_pkix_Attribute_Clear(a); +} diff --git a/security/nss/lib/pkix/src/Attribute/PSetType.c b/security/nss/lib/pkix/src/Attribute/PSetType.c new file mode 100644 index 000000000..8f430aab3 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PSetType.c @@ -0,0 +1,90 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXAttribute_SetType + * + * This routine sets the attribute type oid of the indicated + * NSSPKIXAttribute to the specified value. Since attributes + * may be application-defined, no checking can be done on + * either the correctness of the attribute type oid value nor + * the suitability of the set of attribute values. + * + * The error value may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_OID + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXAttribute_SetType +( + NSSPKIXAttribute *a, + NSSPKIXAttributeType *attributeType +) +{ + NSSDER tmp; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(a) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssOID_verifyPointer(attributeType) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + a->type = attributeType; + + nss_ZFreeIf(a->asn1type.data); + if( (NSSDER *)NULL == nssOID_GetDEREncoding(a->type, &tmp, a->arena) ) { + return PR_FAILURE; + } + + a->asn1type.size = tmp.size; + a->asn1type.data = tmp.data; + + return nss_pkix_Attribute_Clear(a); +} diff --git a/security/nss/lib/pkix/src/Attribute/PSetValue.c b/security/nss/lib/pkix/src/Attribute/PSetValue.c new file mode 100644 index 000000000..4fd490a6a --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PSetValue.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 */ + +/* + * nssPKIXAttribute_SetValue + * + * This routine sets the i'th attribute value {blah blah; copies + * memory contents over..} + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_INVALID_ITEM + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXAttribute_SetValue +( + NSSPKIXAttribute *a, + PRInt32 i, + NSSPKIXAttributeValue *value +) +{ + NSSItem tmp; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(a) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssItem_verifyPointer(value) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( i < 0 ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } + + if( 0 == a->valuesCount ) { + nss_pkix_Attribute_Count(a); + } + + if( (0 != a->valuesCount) && (i > a->valuesCount) ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return PR_FAILURE; + } + + if( (NSSItem *)NULL == nssItem_Duplicate(value, a->arena, &tmp) ) { + return PR_FAILURE; + } + + nss_ZFreeIf(a->asn1values[i]->data); + a->asn1values[i]->size = tmp.size; + a->asn1values[i]->data = tmp.data; + + return nss_pkix_Attribute_Clear(a); +} diff --git a/security/nss/lib/pkix/src/Attribute/PSetValues.c b/security/nss/lib/pkix/src/Attribute/PSetValues.c new file mode 100644 index 000000000..64df8eb55 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/PSetValues.c @@ -0,0 +1,135 @@ +/* + * 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 */ + +/* + * nssPKIXAttribute_SetValues + * + * This routine sets all of the values of the specified + * NSSPKIXAttribute to the values in the specified NSSItem array. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_POINTER + * NSS_ERROR_ARRAY_TOO_SMALL + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXAttribute_SetValues +( + NSSPKIXAttribute *a, + NSSPKIXAttributeValue values[], + PRInt32 count +) +{ + nssASN1Item **ip; + nssASN1Item *newarray; + PRUint32 i; + nssArenaMark *mark; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(a) ) { + return PR_FAILURE; + } + + if( (NSSPKIXAttributeValue *)NULL == values ) { + nss_SetError(NSS_ERROR_INVALID_POINTER); + return PR_FAILURE; + } + + if( count < 1 ) { + nss_SetError(NSS_ERROR_ARRAY_TOO_SMALL); + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + PR_ASSERT((nssASN1Item **)NULL != a->asn1values); + if( (nssASN1Item **)NULL == a->asn1values ) { + nss_SetError(NSS_ERROR_ASSERTION_FAILED); + return PR_FAILURE; + } + + mark = nssArena_Mark(a->arena); + if( (nssArenaMark *)NULL == mark ) { + return PR_FAILURE; + } + + newarray = nss_ZNEWARRAY(a->arena, nssASN1Item *, count); + if( (nssASN1Item *)NULL == newarray ) { + return PR_FAILURE; + } + + for( i = 0; i < count; i++ ) { + NSSItem tmp; + + newarray[i] = nss_ZNEW(a->arena, nssASN1Item); + if( (nssASN1Item *)NULL == newarray[i] ) { + goto loser; + } + + if( (NSSItem *)NULL == nssItem_Duplicate(&values[i], a->arena, &tmp) ) { + goto loser; + } + + newarray[i]->size = tmp.size; + newarray[i]->data = tmp.data; + } + + for( ip = &a->asn1values[0]; *ip; ip++ ) { + nss_ZFreeIf((*ip)->data); + nss_ZFreeIf(*ip); + } + + nss_ZFreeIf(a->asn1values); + + a->asn1values = newarray; + a->valuesCount = count; + + (void)nss_pkix_Attribute_Clear(a); + return nssArena_Unmark(a->arena, mark); + + loser: + (void)nssArena_Release(a->arena, mark); + return PR_FAILURE; +} diff --git a/security/nss/lib/pkix/src/Attribute/RemoveValue.c b/security/nss/lib/pkix/src/Attribute/RemoveValue.c new file mode 100644 index 000000000..e869fd96a --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/RemoveValue.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 */ + +/* + * NSSPKIXAttribute_RemoveValue + * + * This routine removes the i'th attribute value of the set in the + * specified NSSPKIXAttribute. An attempt to remove the last value + * will fail. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_AT_MINIMUM + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAttribute_RemoveValue +( + NSSPKIXAttribute *attribute, + PRInt32 i +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAttribute_RemoveValue(attribute, i); +} + diff --git a/security/nss/lib/pkix/src/Attribute/SetType.c b/security/nss/lib/pkix/src/Attribute/SetType.c new file mode 100644 index 000000000..4975c8f8a --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/SetType.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 */ + +/* + * NSSPKIXAttribute_SetType + * + * This routine sets the attribute type oid of the indicated + * NSSPKIXAttribute to the specified value. Since attributes + * may be application-defined, no checking can be done on + * either the correctness of the attribute type oid value nor + * the suitability of the set of attribute values. + * + * The error value may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_OID + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAttribute_SetType +( + NSSPKIXAttribute *attribute, + NSSPKIXAttributeType *attributeType +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssOID_verifyPointer(attributeType) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAttribute_SetType(attribute, attributeType); +} diff --git a/security/nss/lib/pkix/src/Attribute/SetValue.c b/security/nss/lib/pkix/src/Attribute/SetValue.c new file mode 100644 index 000000000..43f74ad26 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/SetValue.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 */ + +/* + * NSSPKIXAttribute_SetValue + * + * This routine sets the i'th attribute value {blah blah; copies + * memory contents over..} + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_INVALID_ITEM + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAttribute_SetValue +( + NSSPKIXAttribute *attribute, + PRInt32 i, + NSSPKIXAttributeValue *value +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssItem_verifyPointer(value) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAttribute_SetValue(attribute, i, value); +} diff --git a/security/nss/lib/pkix/src/Attribute/SetValues.c b/security/nss/lib/pkix/src/Attribute/SetValues.c new file mode 100644 index 000000000..7c3645cf7 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/SetValues.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 */ + +/* + * NSSPKIXAttribute_SetValues + * + * This routine sets all of the values of the specified + * NSSPKIXAttribute to the values in the specified NSSItem array. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * NSS_ERROR_INVALID_POINTER + * NSS_ERROR_ARRAY_TOO_SMALL + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAttribute_SetValues +( + NSSPKIXAttribute *attribute, + NSSPKIXAttributeValue values[], + PRInt32 count +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttribute_verifyPointer(attribute) ) { + return PR_FAILURE; + } + + if( (NSSPKIXAttributeValue *)NULL == values ) { + nss_SetError(NSS_ERROR_INVALID_POINTER); + return PR_FAILURE; + } + + if( count < 1 ) { + nss_SetError(NSS_ERROR_ARRAY_TOO_SMALL); + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKXIAttribute_SetValues(attribute, values, count); +} diff --git a/security/nss/lib/pkix/src/Attribute/template.c b/security/nss/lib/pkix/src/Attribute/template.c new file mode 100644 index 000000000..850b6a9b0 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/template.c @@ -0,0 +1,58 @@ +/* + * 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 */ + +/* + * nssPKIXAttribute_template + * + * + */ + +const nssASN1Template nssPKIXAttribute_template[] = { + { nssASN1_SEQUENCE, 0, NULL, sizeof(NSSPKIXAttribute) }, + { nssASN1_OBJECT_ID, offsetof(NSSPKIXAttribute, asn1type) }, + { nssASN1_SET_OF, offsetof(NSSPKIXAttribute, asn1values), + nssASN1Template_Any }, + { 0 } +}; diff --git a/security/nss/lib/pkix/src/Attribute/verifyPointer.c b/security/nss/lib/pkix/src/Attribute/verifyPointer.c new file mode 100644 index 000000000..c0ae3ed84 --- /dev/null +++ b/security/nss/lib/pkix/src/Attribute/verifyPointer.c @@ -0,0 +1,170 @@ +/* + * 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_attribute_pointer_tracker; + +/* + * nss_pkix_Attribute_add_pointer + * + * This method is only present in debug builds. + * + * This module-private routine adds an NSSPKIXAttribute 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_Attribute_add_pointer +( + const NSSPKIXAttribute *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_attribute_pointer_tracker); + if( PR_SUCCESS != rv ) { + return rv; + } + + rv = nssPointerTracker_add(&pkix_attribute_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; + } + + return PR_SUCCESS; +} + +/* + * nss_pkix_Attribute_remove_pointer + * + * This method is only present in debug builds. + * + * This module-private routine removes a valid NSSPKIXAttribute + * 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_Attribute_remove_pointer +( + const NSSPKIXAttribute *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_remove(&pkix_attribute_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + } + + return rv; +} + +/* + * nssPKIXAttribute_verifyPointer + * + * This method is only present in debug builds. + * + * If the specified pointer is a valid pointer to an NSSPKIXAttribute + * 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 +nssPKIXAttribute_verifyPointer +( + NSSPKIXAttribute *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_attribute_pointer_tracker); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + rv = nssPointerTracker_verify(&pkix_attribute_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + return PR_SUCCESS; +} + +#endif /* DEBUG */ + diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/Create.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/Create.c new file mode 100644 index 000000000..84e721f80 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/Create.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 */ + +/* + * NSSPKIXAttributeTypeAndValue_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 NSSPKIXAttributeTypeAndValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue * +NSSPKIXAttributeTypeAndValue_Create +( + NSSArena *arenaOpt, + NSSPKIXAttributeType *typeOid, + NSSPKIXAttributeValue *value +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + } + + if( PR_SUCCESS != nssOID_verifyPointer(typeOid) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + + if( PR_SUCCESS != nssItem_verifyPointer(value) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue(arenaOpt, typeOid, value); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/CreateFromUTF8.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/CreateFromUTF8.c new file mode 100644 index 000000000..72e0a3114 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/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 */ + +/* + * NSSPKIXAttributeTypeAndValue_CreateFromUTF8 + * + * + * + * 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 NSSPKIXAttributeTypeAndValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue * +NSSPKIXAttributeTypeAndValue_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *string +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + } + + if( (NSSUTF8 *)NULL == string ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXAttributeTypeAndValue *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_CreateFromUTF8(arenaOpt, string); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/Decode.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/Decode.c new file mode 100644 index 000000000..33b657303 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/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 */ + +/* + * NSSPKIXAttributeTypeAndValue_Decode + * + * + * + * 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 NSSPKIXAttributeTypeAndValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue * +NSSPKIXAttributeTypeAndValue_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_Decode(arenaOpt, ber); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/Destroy.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/Destroy.c new file mode 100644 index 000000000..b3c28a03f --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/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 */ + +/* + * NSSPKIXAttributeTypeAndValue_Destroy + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAttributeTypeAndValue_Destroy +( + NSSPKIXAttributeTypeAndValue *atav +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_Destroy(atav); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/Duplicate.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/Duplicate.c new file mode 100644 index 000000000..09d1f27c3 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/Duplicate.c @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXAttributeTypeAndValue_Duplicate + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXAttributeTypeAndValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue * +NSSPKIXAttributeTypeAndValue_Duplicate +( + NSSPKIXAttributeTypeAndValue *atav, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_Duplicate(atav, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/Encode.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/Encode.c new file mode 100644 index 000000000..1b67be84d --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/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 */ + +/* + * NSSPKIXAttributeTypeAndValue_Encode + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +NSSPKIXAttributeTypeAndValue_Encode +( + NSSPKIXAttributeTypeAndValue *atav, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_Encode(atav, encoding, rvOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/Equal.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/Equal.c new file mode 100644 index 000000000..0cbf06eca --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/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 */ + +/* + * NSSPKIXAttributeTypeAndValue_Equal + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +NSSPKIXAttributeTypeAndValue_Equal +( + NSSPKIXAttributeTypeAndValue *atav1, + NSSPKIXAttributeTypeAndValue *atav2, + PRStatus *statusOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav1) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav2) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_Equal(atav1, atav2, statusOpt); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/GetType.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/GetType.c new file mode 100644 index 000000000..68e2f48f6 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/GetType.c @@ -0,0 +1,71 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXAttributeTypeAndValue_GetType + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSPKIXAttributeType pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeType * +NSSPKIXAttributeTypeAndValue_GetType +( + NSSPKIXAttributeTypeAndValue *atav +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return (NSSPKIXAttributeType *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_GetType(atav); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/GetUTF8Encoding.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/GetUTF8Encoding.c new file mode 100644 index 000000000..611e4bcb9 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/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 */ + +/* + * NSSPKIXAttributeTypeAndValue_GetUTF8Encoding + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSUTF8 pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSUTF8 * +NSSPKIXAttributeTypeAndValue_GetUTF8Encoding +( + NSSPKIXAttributeTypeAndValue *atav, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_GetUTF8Encoding(atav, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/GetValue.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/GetValue.c new file mode 100644 index 000000000..5516c63ea --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/GetValue.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 */ + +/* + * NSSPKIXAttributeTypeAndValue_GetValue + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSAttributeValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeValue * +NSSPKIXAttributeTypeAndValue_GetValue +( + NSSPKIXAttributeTypeAndValue *atav, + NSSPKIXAttributeValue *itemOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return (NSSPKIXAttributeValue *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeValue *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_GetValue(atav, itemOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/MClear.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/MClear.c new file mode 100644 index 000000000..eeae7db86 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/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_AttributeTypeAndValue_Clear + * + * Wipes out cached data. + */ + +NSS_IMPLEMENT PRStatus +nss_pkix_AttributeTypeAndValue_Clear +( + NSSPKIXAttributeTypeAndValue *atav +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( (NSSBER *)NULL != atav->ber ) { + nss_ZFreeIf(atav->ber->data); + nss_ZFreeIf(atav->ber); + } + + if( (NSSDER *)NULL != atav->der ) { + nss_ZFreeIf(atav->der->data); + nss_ZFreeIf(atav->der); + } + + nss_ZFreeIf(atav->utf8); + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PCreate.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PCreate.c new file mode 100644 index 000000000..2dc6d8ac5 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PCreate.c @@ -0,0 +1,154 @@ +/* + * 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 */ + +/* + * nssPKIXAttributeTypeAndValue_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 NSSPKIXAttributeTypeAndValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue * +nssPKIXAttributeTypeAndValue_Create +( + NSSArena *arenaOpt, + NSSPKIXAttributeType *typeOid, + NSSPKIXAttributeValue *value +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAttributeTypeAndValue *rv = (NSSPKIXAttributeTypeAndValue *)NULL; + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + } + + if( PR_SUCCESS != nssOID_verifyPointer(typeOid) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + + if( PR_SUCCESS != nssItem_verifyPointer(value) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } +#endif /* DEBUG */ + + 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, NSSPKIXAttributeTypeAndValue); + if( (NSSPKIXAttributeTypeAndValue *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + rv->type = typeOid; + + { + NSSItem tmp; + if( (NSSItem *)NULL == nssOID_GetDEREncoding(typeOid, arena, &tmp) ) { + goto loser; + } + + rv->asn1type.size = tmp.size; + rv->asn1type.data = tmp.data; + } + + { + NSSItem tmp; + if( (NSSItem *)NULL == nssItem_Duplicate(value, arena, &tmp) ) { + goto loser; + } + + rv->asn1value.size = tmp.size; + rv->asn1value.data = tmp.data; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_AttributeTypeAndValue_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 (NSSPKIXAttributeTypeAndValue *)NULL; +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PCreateFromUTF8.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PCreateFromUTF8.c new file mode 100644 index 000000000..a2fa289ea --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PCreateFromUTF8.c @@ -0,0 +1,137 @@ +/* + * 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 */ + +/* + * nssPKIXAttributeTypeAndValue_CreateFromUTF8 + * + * + * + * 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 NSSPKIXAttributeTypeAndValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue * +nssPKIXAttributeTypeAndValue_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *string +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAttributeTypeAndValue *rv = (NSSPKIXAttributeTypeAndValue *)NULL; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + } + + if( (NSSUTF8 *)NULL == string ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXAttributeTypeAndValue *)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, NSSPKIXAttributeTypeAndValue); + if( (NSSPKIXAttributeTypeAndValue *)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; + } + + /* Fill this in later from ../pki1/atav.c implementation */ + 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_AttributeTypeAndValue_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 (NSSPKIXAttributeTypeAndValue *)NULL; +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PDecode.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PDecode.c new file mode 100644 index 000000000..9e017526c --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PDecode.c @@ -0,0 +1,144 @@ +/* + * 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 */ + +/* + * nssPKIXAttributeTypeAndValue_Decode + * + * + * + * 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 NSSPKIXAttributeTypeAndValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue * +nssPKIXAttributeTypeAndValue_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAttributeTypeAndValue *rv = (NSSPKIXAttributeTypeAndValue *)NULL; + PRStatus status; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeTypeAndValue *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXAttributeTypeAndValue *)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, NSSPKIXAttributeTypeAndValue); + if( (NSSPKIXAttributeTypeAndValue *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + /* For this object, BER is DER */ + rv->der = nssItem_Duplicate(ber, arena, (NSSItem *)NULL); + if( (NSSItem *)NULL == rv->ber ) { + goto loser; + } + + status = nssASN1_DecodeBER(arena, rv, + nssPKIXAttributeTypeAndValue_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_AttributeTypeAndValue_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 (NSSPKIXAttributeTypeAndValue *)NULL; +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PDestroy.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PDestroy.c new file mode 100644 index 000000000..47242f545 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PDestroy.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 */ + +/* + * nssPKIXAttributeTypeAndValue_Destroy + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXAttributeTypeAndValue_Destroy +( + NSSPKIXAttributeTypeAndValue *atav +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + +#ifdef DEBUG + (void)nss_pkix_AttributeTypeAndValue_remove_pointer(atav); + (void)nssArena_RemoveDestructor(arena, + nss_pkix_AttributeTypeAndValue_remove_pointer, atav); +#endif /* DEBUG */ + + if( PR_TRUE == atav->i_allocated_arena ) { + return nssArena_Destroy(atav->arena); + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PDuplicate.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PDuplicate.c new file mode 100644 index 000000000..53fc85171 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PDuplicate.c @@ -0,0 +1,165 @@ +/* + * 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 */ + +/* + * nssPKIXAttributeTypeAndValue_Duplicate + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXAttributeTypeAndValue upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeTypeAndValue * +nssPKIXAttributeTypeAndValue_Duplicate +( + NSSPKIXAttributeTypeAndValue *atav, + NSSArena *arenaOpt +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXAttributeTypeAndValue *rv = (NSSPKIXAttributeTypeAndValue *)NULL; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttributeTypeAndValue *)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, NSSPKIXAttributeTypeAndValue); + if( (NSSPKIXAttributeTypeAndValue *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + + if( (NSSDER *)NULL != atav->der ) { + rv->der = nssItem_Duplicate(atav->der, arena, (NSSItem *)NULL); + if( (NSSDER *)NULL == rv->der ) { + goto loser; /* actually, this isn't fatal */ + } + } + + { + NSSItem src, dst; + src.size = atav->asn1type.size; + src.data = atav->asn1type.data; + if( (NSSItem *)NULL == nssItem_Duplicate(&src, arena, &dst) ) { + goto loser; + } + rv->asn1type.size = dst.size; + rv->asn1type.data = dst.data; + } + + { + NSSItem src, dst; + src.size = atav->asn1value.size; + src.data = atav->asn1value.data; + if( (NSSItem *)NULL == nssItem_Duplicate(&src, arena, &dst) ) { + goto loser; + } + rv->asn1value.size = dst.size; + rv->asn1value.data = dst.data; + } + + rv->type = atav->type; + + if( (NSSUTF8 *)NULL != atav->utf8 ) { + rv->utf8 = nssUTF8_Duplicate(atav->utf8, arena); + if( (NSSUTF8 *)NULL == rv->utf8 ) { + goto loser; /* actually, this isn't fatal */ + } + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_AttributeTypeAndValue_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 (NSSPKIXAttributeTypeAndValue *)NULL; +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PEncode.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PEncode.c new file mode 100644 index 000000000..64a77e590 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PEncode.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 */ + +/* + * nssPKIXAttributeTypeAndValue_Encode + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_EXTERN NSSBER * +nssPKIXAttributeTypeAndValue_Encode +( + NSSPKIXAttributeTypeAndValue *atav, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* NSSDEBUG */ + + switch( encoding ) { + case NSSASN1BER: + case NSSASN1DER: + break; + case NSSASN1CER: + case NSSASN1LWER: + case NSSASN1PER: + default: + nss_SetError(NSS_ERROR_UNSUPPORTED_ENCODING); + return (NSSBER *)NULL; + } + + /* For this item its DER is BER */ + + if( (NSSDER *)NULL == atav->der ) { + atav->der = nssASN1_EncodeDER(atav->arena, (NSSItem *)NULL, a, + nssPKIXAtributeTypeAndValue_template, NSSASN1DER); + if( (NSSDER *)NULL == atav->der ) { + return (NSSBER *)NULL; + } + } + + return nssItem_Duplicate(a->der, arenaOpt, rvOpt); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PEqual.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PEqual.c new file mode 100644 index 000000000..67dc970f1 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PEqual.c @@ -0,0 +1,95 @@ +/* + * 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 */ + +/* + * nssPKIXAttributeTypeAndValue_Equal + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +nssPKIXAttributeTypeAndValue_Equal +( + NSSPKIXAttributeTypeAndValue *atav1, + NSSPKIXAttributeTypeAndValue *atav2, + PRStatus *statusOpt +) +{ + NSSItem one, two; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav1) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav2) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_SUCCESS; + } + + one.size = atav1->asn1type.size; + one.data = atav1->asn1type.data; + two.size = atav2->asn1type.size; + two.data = atav2->asn1type.data; + + if( PR_FALSE == nssItem_Equal(&one, &two, statusOpt) ) { + return PR_FALSE; + } + + one.size = atav1->asn1value.size; + one.data = atav1->asn1value.data; + two.size = atav2->asn1value.size; + two.data = atav2->asn1value.data; + + return nssItem_Equal(&one, &two, statusOpt); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PGetType.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PGetType.c new file mode 100644 index 000000000..20411e8ee --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PGetType.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 */ + +/* + * nssPKIXAttributeTypeAndValue_GetType + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSPKIXAttributeType pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXAttributeType * +nssPKIXAttributeTypeAndValue_GetType +( + NSSPKIXAttributeTypeAndValue *atav +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( (NSSPKIXAttributeType *)NULL == atav->type ) { + NSSItem ber; + + ber.size = atav->asn1type.size; + ber.data = atav->asn1type.data; + + atav->type = (NSSPKIXAttributeType *)NSSOID_CreateFromBER(&ber); + } + + return atav->type; +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PGetUTF8Encoding.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PGetUTF8Encoding.c new file mode 100644 index 000000000..41145b3cf --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/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 */ + +/* + * nssPKIXAttributeTypeAndValue_GetUTF8Encoding + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSUTF8 pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSUTF8 * +nssPKIXAttributeTypeAndValue_GetUTF8Encoding +( + NSSPKIXAttributeTypeAndValue *atav, + NSSArena *arenaOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( (NSSUTF8 *)NULL == atav->utf8 ) { + /* xxx fgmr fill this in from the ../pki1/atav.c implementation */ + } + + return nssUTF8_Duplicate(atav->utf8, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PGetValue.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PGetValue.c new file mode 100644 index 000000000..33f9e5b2b --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PGetValue.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 */ + +/* + * nssPKIXAttributeTypeAndValue_GetValue + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSAttributeValue upon success + * NULL upon failure + */ + +NSS_EXTERN NSSPKIXAttributeValue * +nssPKIXAttributeTypeAndValue_GetValue +( + NSSPKIXAttributeTypeAndValue *atav, + NSSPKIXAttributeValue *rvOpt, + NSSArena *arenaOpt +) +{ + NSSItem tmp; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSDER *)NULL; + } + } +#endif /* NSSDEBUG */ + + tmp.size = atav->asn1value.size; + tmp.data = atav->asn1value.data; + + return nssItem_Duplicate(&tmp, arenaOpt, rvOpt); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PSetType.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PSetType.c new file mode 100644 index 000000000..4e25b88cc --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PSetType.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 */ + +/* + * nssPKIXAttributeTypeAndValue_SetType + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_INVALID_OID + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_EXTERN PRStatus +nssPKIXAttributeTypeAndValue_SetType +( + NSSPKIXAttributeTypeAndValue *atav, + NSSPKIXAttributeType *attributeType +) +{ + NSSDER tmp; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssOID_verifyPointer(attributeType) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + atav->type = attributeType; + + nss_ZFreeIf(atav->asn1type.data); + if( (NSSDER *)NULL == nssOID_GetDEREncoding(atav->type, &tmp, atav->arena) ) { + return PR_FAILURE; + } + + atav->asn1type.size = tmp.size; + atav->asn1type.data = tmp.data; + + return nss_pkix_AttributeTypeAndValue_Clear(atav); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/PSetValue.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/PSetValue.c new file mode 100644 index 000000000..82de4db00 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/PSetValue.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 */ + +/* + * nssPKIXAttributeTypeAndValue_SetValue + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_INVALID_ITEM + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXAttributeTypeAndValue_SetValue +( + NSSPKIXAttributeTypeAndValue *atav, + NSSPKIXAttributeValue *value +) +{ + NSSItem tmp; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssItem_verifyPointer(value) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( (NSSItem *)NULL == nssItem_Duplicate(value, atav->arena, &tmp) ) { + return PR_FAILURE; + } + + nss_ZFreeIf(atav->asn1value.data); + atav->asn1value.size = tmp.size; + atav->asn1value.data = tmp.data; + + return nss_pkix_AttributeTypeAndValue_Clear(atav); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/SetType.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/SetType.c new file mode 100644 index 000000000..672b7b738 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/SetType.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 */ + +/* + * NSSPKIXAttributeTypeAndValue_SetType + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_INVALID_OID + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAttributeTypeAndValue_SetType +( + NSSPKIXAttributeTypeAndValue *atav, + NSSPKIXAttributeType *attributeType +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssOID_verifyPointer(attributeType) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_SetType(atav, attributeType); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/SetValue.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/SetValue.c new file mode 100644 index 000000000..fafc54d6c --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/SetValue.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 */ + +/* + * NSSPKIXAttributeTypeAndValue_SetValue + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATAV + * NSS_ERROR_INVALID_ITEM + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXAttributeTypeAndValue_SetValue +( + NSSPKIXAttributeTypeAndValue *atav, + NSSPKIXAttributeValue *value +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXAttributeTypeAndValue_verifyPointer(atav) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssItem_verifyPointer(value) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXAttributeTypeAndValue_SetValue(atav, value); +} diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/template.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/template.c new file mode 100644 index 000000000..548a4fac9 --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/template.c @@ -0,0 +1,56 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +#ifndef ASN1_H +#include "asn1.h" +#endif /* ASN1_H */ + +/* + * nssPKIXAttributeTypeAndValue_template + * + */ + +const nssASN1Template nssPKIXAttributeTypeAndValue_template[] = { + { nssASN1_SEQUENCE, 0, NULL, sizeof(NSSPKIXAttributeTypeAndValue) }, + { nssASN1_OBJECT_ID, offsetof(NSSPKIXAttributeTypeAndValue, asn1type) }, + { nssASN1_ANY, offsetof(NSSPKIXAttributeTypeAndValue, asn1value) }, + { 0 } +}; diff --git a/security/nss/lib/pkix/src/AttributeTypeAndValue/verifyPointer.c b/security/nss/lib/pkix/src/AttributeTypeAndValue/verifyPointer.c new file mode 100644 index 000000000..340e19c1b --- /dev/null +++ b/security/nss/lib/pkix/src/AttributeTypeAndValue/verifyPointer.c @@ -0,0 +1,184 @@ +/* + * 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_atav_pointer_tracker; + +/* + * nss_pkix_AttributeTypeAndValue_add_pointer + * + * This method is only present in debug builds. + * + * This module-private routine adds an NSSPKIXAttributeTypeAndValue + * 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_AttributeTypeAndValue_add_pointer +( + const NSSPKIXAttributeTypeAndValue *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_atav_pointer_tracker); + if( PR_SUCCESS != rv ) { + return rv; + } + + rv = nssPointerTracker_add(&pkix_atav_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(arena, + nss_pkix_AttributeTypeAndValue_remove_pointer, p); + if( PR_SUCCESS != rv ) { + (void)nss_pkix_AttributeTypeAndValue_remove_pointer(p); + return rv; + } + + return PR_SUCCESS; +} + +/* + * nss_pkix_AttributeTypeAndValue_remove_pointer + * + * This method is only present in debug builds. + * + * This module-private routine removes a valid + * NSSPKIXAttributeTypeAndValue 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_AttributeTypeAndValue_remove_pointer +( + const NSSPKIXAttributeTypeAndValue *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_remove(&pkix_atav_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + } + + /* + * nssArena_deregisterDestructor(p->arena, + * nss_pkix_AttributeTypeAndValue_remove_pointer, p); + */ + + return rv; +} + +/* + * nssPKIXAttributeTypeAndValue_verifyPointer + * + * This method is only present in debug builds. + * + * If the specified pointer is a valid pointer to an + * NSSPKIXAttributeTypeAndValue 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 +nssPKIXAttributeTypeAndValue_verifyPointer +( + NSSPKIXAttributeTypeAndValue *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_atav_pointer_tracker); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + rv = nssPointerTracker_verify(&pkix_atav_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + return PR_SUCCESS; +} + +#endif /* DEBUG */ + diff --git a/security/nss/lib/pkix/src/Name/Create.c b/security/nss/lib/pkix/src/Name/Create.c new file mode 100644 index 000000000..dc9059f0b --- /dev/null +++ b/security/nss/lib/pkix/src/Name/Create.c @@ -0,0 +1,93 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_Create + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_CHOICE + * NSS_ERROR_INVALID_ARGUMENT + * + * Return value: + * A valid pointer to an NSSPKIXName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXName * +NSSPKIXName_Create +( + NSSArena *arenaOpt, + NSSPKIXNameChoice choice, + void *arg +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXName *)NULL; + } + } + + switch( choice ) { + case NSSPKIXNameChoice_rdnSequence: + { + NSSPKIXRDNSequence *r = (NSSPKIXRDNSequence *)arg; + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(r) ) { + return (NSSPKIXName *)NULL; + } + } + + break; + case NSSPKIXNameChoice_NSSinvalid: + default: + nss_SetError(NSS_ERROR_INVALID_CHOICE); + return (NSSPKIXName *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXName_Create(arenaOpt, choice, arg); +} diff --git a/security/nss/lib/pkix/src/Name/CreateFromRDNSequence.c b/security/nss/lib/pkix/src/Name/CreateFromRDNSequence.c new file mode 100644 index 000000000..da07742cc --- /dev/null +++ b/security/nss/lib/pkix/src/Name/CreateFromRDNSequence.c @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_CreateFromRDNSequence + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * + * Return value: + * A valid pointer to an NSSPKIXName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXName * +NSSPKIXName_CreateFromRDNSequence +( + NSSArena *arenaOpt, + NSSPKIXRDNSequence *rdnSequence +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXName *)NULL; + } + } + + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnSequence) ) { + return (NSSPKIXName *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXName_CreateFromRDNSequence(arenaOpt, rdnSequence); +} diff --git a/security/nss/lib/pkix/src/Name/CreateFromUTF8.c b/security/nss/lib/pkix/src/Name/CreateFromUTF8.c new file mode 100644 index 000000000..f2111ea75 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/CreateFromUTF8.c @@ -0,0 +1,81 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_CreateFromUTF8 + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_STRING + * NSS_ERROR_UNKNOWN_ATTRIBUTE + * + * Return value: + * A valid pointer to an NSSPKIXName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXName * +NSSPKIXName_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *string +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXName *)NULL; + } + } + + if( (NSSUTF8 *)NULL == string ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXName_CreateFromUTF8(arenaOpt, string); +} diff --git a/security/nss/lib/pkix/src/Name/Decode.c b/security/nss/lib/pkix/src/Name/Decode.c new file mode 100644 index 000000000..b30fac01e --- /dev/null +++ b/security/nss/lib/pkix/src/Name/Decode.c @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_CreateFromBER + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_BER + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXName * +NSSPKIXName_CreateFromBER +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXName *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXName *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXName_CreateFromBER(arenaOpt, ber); +} diff --git a/security/nss/lib/pkix/src/Name/Destroy.c b/security/nss/lib/pkix/src/Name/Destroy.c new file mode 100644 index 000000000..c8c2bc9f2 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/Destroy.c @@ -0,0 +1,71 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_Destroy + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXName_Destroy +( + NSSPKIXName *name +) +{ +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXName_Destroy(name); +} diff --git a/security/nss/lib/pkix/src/Name/Duplicate.c b/security/nss/lib/pkix/src/Name/Duplicate.c new file mode 100644 index 000000000..6c8831729 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/Duplicate.c @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_Duplicate + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXName * +NSSPKIXName_Duplicate +( + NSSPKIXName *name, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return (NSSDER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSDER *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXName_Duplicate(name, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Name/Encode.c b/security/nss/lib/pkix/src/Name/Encode.c new file mode 100644 index 000000000..344a53724 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/Encode.c @@ -0,0 +1,81 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_Encode + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +NSSPKIXName_Encode +( + NSSPKIXName *name, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXName_Encode(name, rvOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Name/Equal.c b/security/nss/lib/pkix/src/Name/Equal.c new file mode 100644 index 000000000..9a74eef94 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/Equal.c @@ -0,0 +1,85 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_Equal + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +NSSPKIXName_Equal +( + NSSPKIXName *name1, + NSSPKIXName *name2, + PRStatus *statusOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(name1) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(name2) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; + } +#endif /* DEBUG */ + + return nssPKIX_Equal(name1, name2, statusOpt); +} diff --git a/security/nss/lib/pkix/src/Name/GetChoice.c b/security/nss/lib/pkix/src/Name/GetChoice.c new file mode 100644 index 000000000..8a36ada00 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/GetChoice.c @@ -0,0 +1,70 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_GetChoice + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * + * Return value: + * A valid element of the NSSPKIXNameChoice enumeration upon success + * The value NSSPKIXNameChoice_NSSinvalid (-1) upon error + */ + +NSS_IMPLEMENT NSSPKIXNameChoice +NSSPKIXName_GetChoice +( + NSSPKIXName *name +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return NSSPKIXNameChoice_NSSinvalid; + } +#endif /* DEBUG */ + + return nssPKIXName_GetChoice(name); +} diff --git a/security/nss/lib/pkix/src/Name/GetRDNSequence.c b/security/nss/lib/pkix/src/Name/GetRDNSequence.c new file mode 100644 index 000000000..94562ae3c --- /dev/null +++ b/security/nss/lib/pkix/src/Name/GetRDNSequence.c @@ -0,0 +1,80 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_GetRDNSequence + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_WRONG_CHOICE + * + * Return value: + * A pointer to a valid NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +NSSPKIXName_GetRDNSequence +( + NSSPKIXName *name, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return (NSSPKIXRDNSequence *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRDNSequence *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXName_GetRDNSequence(name, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Name/GetSpecifiedChoice.c b/security/nss/lib/pkix/src/Name/GetSpecifiedChoice.c new file mode 100644 index 000000000..3de2d5b84 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/GetSpecifiedChoice.c @@ -0,0 +1,90 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_GetSpecifiedChoice + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_WRONG_CHOICE + * + * Return value: + * A valid pointer ... + * NULL upon failure + */ + +NSS_IMPLEMENT void * +NSSPKIXName_GetSpecifiedChoice +( + NSSPKIXName *name, + NSSPKIXNameChoice choice, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(name) ) { + return (void *)NULL; + } + + switch( choice ) { + case NSSPKIXNameChoice_rdnSequence: + break; + case NSSPKIXNameChoice_NSSinvalid: + default: + nss_SetError(NSS_ERROR_INVALID_CHOICE); + return (void *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (void *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXName_GetSpecifiedChoice(name, choice, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Name/GetUTF8Encoding.c b/security/nss/lib/pkix/src/Name/GetUTF8Encoding.c new file mode 100644 index 000000000..c86dd94b2 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/GetUTF8Encoding.c @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXName_GetUTF8Encoding + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSUTF8 pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSUTF8 * +NSSPKIXName_GetUTF8Encoding +( + NSSPKIXName *name, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXName_GetUTF8Encoding(name, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Name/MClear.c b/security/nss/lib/pkix/src/Name/MClear.c new file mode 100644 index 000000000..e8d6b1961 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/MClear.c @@ -0,0 +1,73 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nss_pkix_Name_Clear + * + * Wipes out cached data. + */ + +NSS_IMPLEMENT PRStatus +nss_pkix_Name_Clear +( + NSSPKIXName *name +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( (NSSBER *)NULL != name->ber ) { + nss_ZFreeIf(name->ber->data); + nss_ZFreeIf(name->ber); + } + + if( (NSSDER *)NULL != name->der ) { + nss_ZFreeIf(name->der->data); + nss_ZFreeIf(name->der); + } + + nss_ZFreeIf(name->utf8); + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/Name/Mregister.c b/security/nss/lib/pkix/src/Name/Mregister.c new file mode 100644 index 000000000..09ddb9d99 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/Mregister.c @@ -0,0 +1,72 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +#ifdef NSSDEBUG +/* + * nss_pkix_Name_register + * + * Registers whatever sub-component exists within this Name. + */ + +NSS_IMPLEMENT PRStatus +nss_pkix_Name_register +( + NSSPKIXName *name +) +{ + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return PR_FAILURE; + } + + switch( name->choice ) { + case NSSPKIXNameChoice_rdnSequence: + /* add pointer */ + /* (sub-)register pointer */ + /* add destructor to arena */ + break; + case NSSPKIXNameChoice_NSSinvalid: + default: + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + return PR_FAILURE; + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/Name/PCreate.c b/security/nss/lib/pkix/src/Name/PCreate.c new file mode 100644 index 000000000..e93737599 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PCreate.c @@ -0,0 +1,173 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_Create + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_CHOICE + * NSS_ERROR_INVALID_ARGUMENT + * + * Return value: + * A valid pointer to an NSSPKIXName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXName * +nssPKIXName_Create +( + NSSArena *arenaOpt, + NSSPKIXNameChoice choice, + void *arg +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXName *rv = (NSSPKIXName *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXName *)NULL; + } + } + + switch( choice ) { + case NSSPKIXNameChoice_rdnSequence: + if( (PR_SUCCESS != nssPKIXRDNSequence_verifyPointer((NSSPKIXRDNSequence *)arg) ) ) { + nss_SetError(NSS_ERROR_INVALID_ARGUMENT); + return (NSSPKIXName *)NULL; + } + break; + case NSSPKIXNameChoice_NSSinvalid: + default: + nss_SetError(NSS_ERROR_INVALID_CHOICE); + return (NSSPKIXName *)NULL; + } +#endif /* NSSDEBUG */ + + switch( choice ) { + case NSSPKIXNameChoice_rdnSequence: + break; + case NSSPKIXNameChoice_NSSinvalid: + default: + nss_SetError(NSS_ERROR_INVALID_CHOICE); + goto loser; + } + + if( (NSSArena *)NULL == arenaOpt ) { + arena = nssArena_Create(); + if( (NSSArena *)NULL == arena ) { + goto loser; + } + arena_allocated = PR_TRUE; + } else { + arena = arenaOpt; + mark = nssArena_Mark(arena); + if( (nssArenaMark *)NULL == mark ) { + goto loser; + } + } + + rv = nss_ZNEW(arena, NSSPKIXName); + if( (NSSPKIXName *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + rv->utf8 = nssUTF8_Duplicate(string, arena); + if( (NSSUTF8 *)NULL == rv->utf8 ) { + goto loser; + } + + rv->choice = choice; + switch( choice ) { + case NSSPKIXNameChoice_rdnSequence: + rv->u.rdnSequence = nssPKIXRDNSequence_Duplicate((NSSPKIXRDNSequence *)arg, arena); + if( (NSSPKIXRDNSequence *)NULL == rv->u.rdnSequence ) { + goto loser; + } + break; + case NSSPKIXNameChoice_NSSinvalid: + default: + nss_SetError(NSS_ERROR_INVALID_CHOICE); + goto loser; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_Name_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != nssArena_registerDestructor(arena, + nss_pkix_Name_remove_pointer, rv) ) { + (void)nss_pkix_Name_remove_pointer(rv); + goto loser; + } +#endif /* DEBUG */ + + return rv; + + loser: + if( (nssArenaMark *)NULL != mark ) { + (void)nssArena_Release(arena, mark); + } + + if( PR_TRUE == arena_allocated ) { + (void)nssArena_Destroy(arena); + } + + return (NSSPKIXName *)NULL; +} diff --git a/security/nss/lib/pkix/src/Name/PCreateFromRDNSequence.c b/security/nss/lib/pkix/src/Name/PCreateFromRDNSequence.c new file mode 100644 index 000000000..169e409a3 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PCreateFromRDNSequence.c @@ -0,0 +1,145 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_CreateFromRDNSequence + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * + * Return value: + * A valid pointer to an NSSPKIXName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXName * +nssPKIXName_CreateFromRDNSequence +( + NSSArena *arenaOpt, + NSSPKIXRDNSequence *rdnSequence +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXName *rv = (NSSPKIXName *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXName *)NULL; + } + } + + if( (PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnSequence) ) ) { + return (NSSPKIXName *)NULL; + } +#endif /* NSSDEBUG */ + + if( (NSSArena *)NULL == arenaOpt ) { + arena = nssArena_Create(); + if( (NSSArena *)NULL == arena ) { + goto loser; + } + arena_allocated = PR_TRUE; + } else { + arena = arenaOpt; + mark = nssArena_Mark(arena); + if( (nssArenaMark *)NULL == mark ) { + goto loser; + } + } + + rv = nss_ZNEW(arena, NSSPKIXName); + if( (NSSPKIXName *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + rv->utf8 = nssUTF8_Duplicate(string, arena); + if( (NSSUTF8 *)NULL == rv->utf8 ) { + goto loser; + } + + rv->choice = NSSPKIXNameChoice_rdnSequence; + rv->u.rdnSequence = nssPKIXRDNSequence_Duplicate(rdnSequence, arena); + if( (NSSPKIXRDNSequence *)NULL == rv->u.rdnSequence ) { + goto loser; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_Name_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != nssArena_registerDestructor(arena, + nss_pkix_Name_remove_pointer, rv) ) { + (void)nss_pkix_Name_remove_pointer(rv); + goto loser; + } +#endif /* DEBUG */ + + return rv; + + loser: + if( (nssArenaMark *)NULL != mark ) { + (void)nssArena_Release(arena, mark); + } + + if( PR_TRUE == arena_allocated ) { + (void)nssArena_Destroy(arena); + } + + return (NSSPKIXName *)NULL; +} diff --git a/security/nss/lib/pkix/src/Name/PCreateFromUTF8.c b/security/nss/lib/pkix/src/Name/PCreateFromUTF8.c new file mode 100644 index 000000000..0939a19e3 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PCreateFromUTF8.c @@ -0,0 +1,145 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_CreateFromUTF8 + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_STRING + * NSS_ERROR_UNKNOWN_ATTRIBUTE + * + * Return value: + * A valid pointer to an NSSPKIXName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXName * +nssPKIXName_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *string +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXName *rv = (NSSPKIXName *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXName *)NULL; + } + } + + if( (NSSUTF8 *)NULL == string ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXName *)NULL; + } +#endif /* NSSDEBUG */ + + if( (NSSArena *)NULL == arenaOpt ) { + arena = nssArena_Create(); + if( (NSSArena *)NULL == arena ) { + goto loser; + } + arena_allocated = PR_TRUE; + } else { + arena = arenaOpt; + mark = nssArena_Mark(arena); + if( (nssArenaMark *)NULL == mark ) { + goto loser; + } + } + + rv = nss_ZNEW(arena, NSSPKIXName); + if( (NSSPKIXName *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + rv->utf8 = nssUTF8_Duplicate(string, arena); + if( (NSSUTF8 *)NULL == rv->utf8 ) { + goto loser; + } + + /* Insert intelligence here -- fgmr */ + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + goto loser; + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_Name_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != nssArena_registerDestructor(arena, + nss_pkix_Name_remove_pointer, rv) ) { + (void)nss_pkix_Name_remove_pointer(rv); + goto loser; + } +#endif /* DEBUG */ + + return rv; + + loser: + if( (nssArenaMark *)NULL != mark ) { + (void)nssArena_Release(arena, mark); + } + + if( PR_TRUE == arena_allocated ) { + (void)nssArena_Destroy(arena); + } + + return (NSSPKIXName *)NULL; +} diff --git a/security/nss/lib/pkix/src/Name/PDecode.c b/security/nss/lib/pkix/src/Name/PDecode.c new file mode 100644 index 000000000..d3f20d473 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PDecode.c @@ -0,0 +1,138 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_CreateFromBER + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_BER + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXName * +nssPKIXName_CreateFromBER +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXName *rv = (NSSPKIXName *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXName *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXName *)NULL; + } +#endif /* NSSDEBUG */ + + if( (NSSArena *)NULL == arenaOpt ) { + arena = nssArena_Create(); + if( (NSSArena *)NULL == arena ) { + goto loser; + } + arena_allocated = PR_TRUE; + } else { + arena = arenaOpt; + mark = nssArena_Mark(arena); + if( (nssArenaMark *)NULL == mark ) { + goto loser; + } + } + + rv = nss_ZNEW(arena, NSSPKIXName); + if( (NSSPKIXName *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + rv->ber = nssItem_Duplicate(ber, arena, (NSSItem *)NULL); + if( (NSSItem *)NULL == rv->ber ) { + goto loser; + } + + status = nssASN1_DecodeBER(arena, rv, nssPKIXName_template, ber); + if( PR_SUCCESS != status ) { + goto loser; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_Name_add_pointer(rv) ) { + goto loser; + } +#endif /* DEBUG */ + + return rv; + + loser: + if( (nssArenaMark *)NULL != mark ) { + (void)nssArena_Release(arena, mark); + } + + if( PR_TRUE == arena_allocated ) { + (void)nssArena_Destroy(arena); + } + + return (NSSPKIXName *)NULL; +} diff --git a/security/nss/lib/pkix/src/Name/PDestroy.c b/security/nss/lib/pkix/src/Name/PDestroy.c new file mode 100644 index 000000000..f1fd41721 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PDestroy.c @@ -0,0 +1,76 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_Destroy + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXName_Destroy +( + NSSPKIXName *name +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + +#ifdef DEBUG + (void)nss_pkix_Name_remove_pointer(name); +#endif /* DEBUG */ + + if( PR_TRUE == name->i_allocated_arena ) { + return nssArena_Destroy(name->arena); + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/Name/PDuplicate.c b/security/nss/lib/pkix/src/Name/PDuplicate.c new file mode 100644 index 000000000..c5788a0f1 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PDuplicate.c @@ -0,0 +1,172 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_Duplicate + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXName * +nssPKIXName_Duplicate +( + NSSPKIXName *name, + NSSArena *arenaOpt +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXName *rv = (NSSPKIXName *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXName *)NULL; + } + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( (NSSArena *)NULL == arenaOpt ) { + arena = nssArena_Create(); + if( (NSSArena *)NULL == arena ) { + goto loser; + } + arena_allocated = PR_TRUE; + } else { + arena = arenaOpt; + mark = nssArena_Mark(arena); + if( (nssArenaMark *)NULL == mark ) { + goto loser; + } + } + + rv = nss_ZNEW(arena, NSSPKIXName); + if( (NSSPKIXName *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + + if( (NSSBER *)NULL != name->ber ) { + rv->ber = nssItem_Duplicate(name->ber, arena, (NSSItem *)NULL); + if( (NSSBER *)NULL == rv->ber ) { + goto loser; + } + } + + if( (NSSDER *)NULL != name->der ) { + rv->der = nssItem_Duplicate(name->der, arena, (NSSItem *)NULL); + if( (NSSDER *)NULL == rv->der ) { + goto loser; + } + } + + if( (NSSUTF8 *)NULL != name->utf8 ) { + rv->utf8 = nssUTF8_duplicate(name->utf8, arena); + if( (NSSUTF8 *)NULL == rv->utf8 ) { + goto loser; + } + } + + rv->choice = name->choice; + switch( name->choice ) { + case NSSPKIXNameChoice_rdnSequence: + rv->u.rdnSequence = nssPKIXRDNSequence_Duplicate(name->u.rdnSequence, arena); + if( (NSSPKIXRDNSequence *)NULL == rv->u.rdnSequence ) { + goto loser; + } + break; + case NSSPKIXNameChoice_NSSinvalid: + default: + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + goto loser; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_Name_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != nssArena_registerDestructor(arena, + nss_pkix_Name_remove_pointer, rv) ) { + (void)nss_pkix_Name_remove_pointer(rv); + goto loser; + } +#endif /* DEBUG */ + + return rv; + + loser: + if( (nssArenaMark *)NULL != mark ) { + (void)nssArena_Release(arena, mark); + } + + if( PR_TRUE == arena_allocated ) { + (void)nssArena_Destroy(arena); + } + + return (NSSPKIXName *)NULL; +} diff --git a/security/nss/lib/pkix/src/Name/PEncode.c b/security/nss/lib/pkix/src/Name/PEncode.c new file mode 100644 index 000000000..469b528fb --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PEncode.c @@ -0,0 +1,118 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_Encode + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +nssPKIXName_Encode +( + NSSPKIXName *name, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + NSSBER *it; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* NSSDEBUG */ + + switch( encoding ) { + case NSSASN1BER: + if( (NSSBER *)NULL != name->ber ) { + it = name->ber; + goto done; + } + /*FALLTHROUGH*/ + case NSSASN1DER: + if( (NSSDER *)NULL != name->der ) { + it = name->der; + goto done; + } + break; + default: + nss_SetError(NSS_ERROR_UNSUPPORTED_ENCODING); + return (NSSBER *)NULL; + } + + it = nssASN1_EncodeItem(name->arena, (NSSItem *)NULL, name, + nssPKIXName_template, encoding); + if( (NSSBER *)NULL == it ) { + return (NSSBER *)NULL; + } + + switch( encoding ) { + case NSSASN1BER: + name->ber = it; + break; + case NSSASN1DER: + name->der = it; + break; + default: + PR_ASSERT(0); + break; + } + + done: + return nssItem_Duplicate(it, arenaOpt, rvOpt); +} diff --git a/security/nss/lib/pkix/src/Name/PEqual.c b/security/nss/lib/pkix/src/Name/PEqual.c new file mode 100644 index 000000000..5ad91dd2a --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PEqual.c @@ -0,0 +1,104 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_Equal + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +nssPKIXName_Equal +( + NSSPKIXName *one, + NSSPKIXName *two, + PRStatus *statusOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(one) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXName_verifyPointer(two) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } +#endif /* NSSDEBUG */ + + if( ((NSSDER *)NULL != one->der) && ((NSSDER *)NULL != two->der) ) { + return nssItem_Equal(one->der, two->der, statusOpt); + } + + if( one->choice != two->choice ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_SUCCESS; + } + return PR_FALSE; + } + + switch( one->choice ) { + case NSSPKIXNameChoice_rdnSequence: + return nssPKIXRDNSequence_Equal(one->u.rdnSequence, two->u.rdnSequence, statusOpt); + case NSSPKIXNameChoice_NSSinvalid: + default: + break; + } + + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; +} diff --git a/security/nss/lib/pkix/src/Name/PGetChoice.c b/security/nss/lib/pkix/src/Name/PGetChoice.c new file mode 100644 index 000000000..f34a93908 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PGetChoice.c @@ -0,0 +1,68 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_GetChoice + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * + * Return value: + * A valid element of the NSSPKIXNameChoice enumeration upon success + * The value NSSPKIXNameChoice_NSSinvalid (-1) upon error + */ + +NSS_IMPLEMENT NSSPKIXNameChoice +nssPKIXName_GetChoice +( + NSSPKIXName *name +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return NSSPKIXNameChoice_NSSinvalid; + } +#endif /* NSSDEBUG */ + + return name->choice; +} diff --git a/security/nss/lib/pkix/src/Name/PGetRDNSequence.c b/security/nss/lib/pkix/src/Name/PGetRDNSequence.c new file mode 100644 index 000000000..0899e550d --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PGetRDNSequence.c @@ -0,0 +1,87 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_GetRDNSequence + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_WRONG_CHOICE + * + * Return value: + * A pointer to a valid NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +nssPKIXName_GetRDNSequence +( + NSSPKIXName *name, + NSSArena *arenaOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return (NSSPKIXRDNSequence *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRDNSequence *)NULL; + } + } +#endif /* NSSDEBUG */ + + switch( name->choice ) { + case NSSPKIXNameChoice_rdnSequence: + return nssPKIXRDNSequence_Duplicate(name->u.rdnSequence, arenaOpt); + case NSSPKIXNameChoice_NSSinvalid: + default: + break; + } + + nss_SetError(NSS_ERROR_WRONG_CHOICE); + return (NSSPKIXRDNSequence *)NULL; +} diff --git a/security/nss/lib/pkix/src/Name/PGetSpecifiedChoice.c b/security/nss/lib/pkix/src/Name/PGetSpecifiedChoice.c new file mode 100644 index 000000000..a24c8ea86 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PGetSpecifiedChoice.c @@ -0,0 +1,93 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_GetSpecifiedChoice + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_WRONG_CHOICE + * + * Return value: + * A valid pointer ... + * NULL upon failure + */ + +NSS_IMPLEMENT void * +nssPKIXName_GetSpecifiedChoice +( + NSSPKIXName *name, + NSSPKIXNameChoice choice, + NSSArena *arenaOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return (void *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (void *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( choice != name->choice ) { + nss_SetError(NSS_ERROR_WRONG_CHOICE); + return (void *)NULL; + } + + switch( name->choice ) { + case NSSPKIXNameChoice_rdnSequence: + return (void *)nssPKIXRDNSequence_Duplicate(name->u.rdnSequence, arenaOpt); + case NSSPKIXNameChoice_NSSinvalid: + default: + break; + } + + nss_SetError(NSS_ERROR_WRONG_CHOICE); + return (NSSPKIXRDNSequence *)NULL; +} diff --git a/security/nss/lib/pkix/src/Name/PGetUTF8Encoding.c b/security/nss/lib/pkix/src/Name/PGetUTF8Encoding.c new file mode 100644 index 000000000..164229277 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/PGetUTF8Encoding.c @@ -0,0 +1,81 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXName_GetUTF8Encoding + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_NAME + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSUTF8 pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSUTF8 * +nssPKIXName_GetUTF8Encoding +( + NSSPKIXName *name, + NSSArena *arenaOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXName_verifyPointer(name) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( (NSSUTF8 *)NULL == name->utf8 ) { + /* xxx fgmr fill this in from pki1 implementation */ + } + + return nssUTF8_Duplicate(name->utf8, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Name/template.c b/security/nss/lib/pkix/src/Name/template.c new file mode 100644 index 000000000..72ac85466 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/template.c @@ -0,0 +1,56 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +#ifndef ASN1_H +#include "asn1.h" +#endif /* ASN1_H */ + +/* + * nssPKIXName_template + * + */ + +const nssASN1Template nssPKIXName_template[] = { + { nssASN1_CHOICE, offsetof(NSSPKIXName, choice), 0, sizeof(NSSPKIXName) }, + { nssASN1_POINTER, offsetof(NSSPKIXName, u.rdnSequence), + nssPKIXRDNSequence_template, NSSPKIXNameChoice_rdnSequence }, + { 0 } +}; diff --git a/security/nss/lib/pkix/src/Name/verifyPointer.c b/security/nss/lib/pkix/src/Name/verifyPointer.c new file mode 100644 index 000000000..6c27e5910 --- /dev/null +++ b/security/nss/lib/pkix/src/Name/verifyPointer.c @@ -0,0 +1,210 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIXM_H +#include "pkixm.h" +#endif /* PKIXM_H */ + +#ifdef DEBUG + +extern const NSSError NSS_ERROR_INTERNAL_ERROR; + +static nssPointerTracker pkix_name_pointer_tracker; + +/* + * nss_pkix_Name_add_pointer + * + * This method is only present in debug builds. + * + * This module-private routine adds an NSSPKIXName pointer to + * the internal pointer-tracker. This routine should only be used + * by the NSSPKIX module. This routine returns a PRStatus value; + * upon error it will place an error on the error stack and return + * PR_FAILURE. + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INTERNAL_ERROR + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nss_pkix_Name_add_pointer +( + const NSSPKIXName *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_name_pointer_tracker); + if( PR_SUCCESS != rv ) { + return rv; + } + + rv = nssPointerTracker_add(&pkix_name_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + NSSError e = NSS_GetError(); + if( NSS_ERROR_NO_MEMORY != e ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + } + + return rv; + } + + rv = nssArena_registerDestructor(p->arena, + nss_pkix_Name_remove_pointer, p); + if( PR_SUCCESS != rv ) { + (void)nss_pkix_Name_remove_pointer(p); + return rv; + } + +#ifdef NSSDEBUG + switch( p->choice ) { + case NSSPKIXNameChoice_rdnSequence: + rv = nss_pkix_RDNSequence_register(p->u.rdnSequence); + break; + case NSSPKIXNameChoice_NSSinvalid: + default: + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + rv = PR_FAILURE; + break; + } + + if( PR_SUCCESS != rv ) { + (void)nss_pkix_Name_remove_pointer(p); + } +#endif /* NSSDEBUG */ + + return rv; +} + +/* + * nss_pkix_Name_remove_pointer + * + * This method is only present in debug builds. + * + * This module-private routine removes a valid NSSPKIXName + * pointer from the internal pointer-tracker. This routine should + * only be used by the NSSPKIX module. This routine returns a + * PRStatus value; upon error it will place an error on the error + * stack and return PR_FAILURE. + * + * The error may be one of the following values: + * NSS_ERROR_INTERNAL_ERROR + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nss_pkix_Name_remove_pointer +( + const NSSPKIXName *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_remove(&pkix_name_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + } + +#ifdef NSSDEBUG + switch( p->choice ) { + case NSSPKIXNameChoice_rdnSequence: + (void)nss_pkix_RDNSequence_register(p->u.rdnSequence); + break; + case NSSPKIXNameChoice_NSSinvalid: + default: + break; + } +#endif /* NSSDEBUG */ + + /* + * nssArena_deregisterDestructor(p->arena, + * nss_pkix_Name_remove_pointer, p); + */ + + return rv; +} + +/* + * nssPKIXName_verifyPointer + * + * This method is only present in debug builds. + * + * If the specified pointer is a valid pointer to an NSSPKIXName + * object, this routine will return PR_SUCCESS. Otherwise, it will + * put an error on the error stack and return PR_FAILURE. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_ATTRIBUTE + * + * Return value: + * PR_SUCCESS if the pointer is valid + * PR_FAILURE if it isn't + */ + +NSS_IMPLEMENT PRStatus +nssPKIXName_verifyPointer +( + NSSPKIXName *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_name_pointer_tracker); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + rv = nssPointerTracker_verify(&pkix_name_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + return PR_SUCCESS; +} + +#endif /* DEBUG */ + diff --git a/security/nss/lib/pkix/src/RDNSequence/AppendRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/AppendRelativeDistinguishedName.c new file mode 100644 index 000000000..4e0d0d018 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/AppendRelativeDistinguishedName.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 */ + +/* + * NSSPKIXRDNSequence_AppendRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRDNSequence_AppendRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + NSSPKIXRelativeDistinguishedName *rdn +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_AppendRelativeDistinguishedName(rdnseq, rdn); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/Create.c b/security/nss/lib/pkix/src/RDNSequence/Create.c new file mode 100644 index 000000000..52b8a851c --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * NSSPKIXRDNSequence_Create + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_PKIX_RDN + * + * Return value: + * A valid pointer to an NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +NSSPKIXRDNSequence_Create +( + NSSArena *arenaOpt, + NSSPKIXRelativeDistinguishedName *rdn1, + ... +) +{ + va_list ap; + NSSPKIXRDNSequence *rv; + PRUint32 count; + + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRDNSequence *)NULL; + } + } + + /* Is there a nonzero minimum number of RDNs required? */ + + { + va_start(ap, arenaOpt); + + while( 1 ) { + NSSPKIXRelativeDistinguishedName *rdn; + rdn = (NSSPKIXRelativeDistinguishedName *)va_arg(ap, NSSPKIXRelativeDistinguishedName *); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rdn ) { + break; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + va_end(ap); + return (NSSPKIXRDNSequence *)NULL; + } + } + + va_end(ap); + } +#endif /* DEBUG */ + + va_start(ap, arenaOpt); + + for( count = 0; ; count++ ) { + NSSPKIXRelativeDistinguishedName *rdn; + rdn = (NSSPKIXRelativeDistinguishedName *)va_arg(ap, NSSPKIXRelativeDistinguishedName *); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rdn ) { + break; + } + +#ifdef PEDANTIC + if( count == 0xFFFFFFFF ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + va_end(ap); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* PEDANTIC */ + } + + va_end(ap); + + va_start(ap, arenaOpt); + rv = nss_pkix_RDNSequence_V_Create(arenaOpt, count, ap); + va_end(ap); + + return rv; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/CreateFromArray.c b/security/nss/lib/pkix/src/RDNSequence/CreateFromArray.c new file mode 100644 index 000000000..b6412187c --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * NSSPKIXRDNSequence_CreateFromArray + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_PKIX_RDN + * + * Return value: + * A valid pointer to an NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +NSSPKIXRDNSequence_Create +( + NSSArena *arenaOpt, + PRUint32 count, + NSSPKIXRelativeDistinguishedName *rdns[] +) +{ + 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 != nssPKIXRelativeDistinguishedName_verifyPointer(&rdns[i]) ) { + return (NSSPKIXAttribute *)NULL; + } + } + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_CreateFromArray(arenaOpt, count, rnds); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/CreateFromUTF8.c b/security/nss/lib/pkix/src/RDNSequence/CreateFromUTF8.c new file mode 100644 index 000000000..dcdbc54a2 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * NSSPKIXRDNSequence_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 NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +NSSPKIXRDNSequence_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *string +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRDNSequence *)NULL; + } + } + + if( (NSSUTF8 *)NULL == string ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXRDNSequence *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_CreateFromUTF8(arenaOpt, string); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/Decode.c b/security/nss/lib/pkix/src/RDNSequence/Decode.c new file mode 100644 index 000000000..ebbad116a --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * NSSPKIXRDNSequence_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 NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +NSSPKIXRDNSequence_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRDNSequence *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXRDNSequence *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_Decode(arenaOpt, ber); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/Destroy.c b/security/nss/lib/pkix/src/RDNSequence/Destroy.c new file mode 100644 index 000000000..5962364e5 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * NSSPKIXRDNSequence_Destroy + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRDNSequence_Destroy +( + NSSPKIXRDNSequence *rdnseq +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_Destroy(rdnseq); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/Duplicate.c b/security/nss/lib/pkix/src/RDNSequence/Duplicate.c new file mode 100644 index 000000000..2bf53ba59 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/Duplicate.c @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXRDNSequence_Duplicate + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +NSSPKIXRDNSequence_Duplicate +( + NSSPKIXRDNSequence *rdnseq, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return (NSSPKIXRDNSequence *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRDNSequence *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_Duplicate(rdnseq, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/Encode.c b/security/nss/lib/pkix/src/RDNSequence/Encode.c new file mode 100644 index 000000000..84ab4db67 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * NSSPKIXRDNSequence_Encode + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +NSSPKIXRDNSequence_Encode +( + NSSPKIXRDNSequence *rdnseq, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_Encode(rdnseq, encoding, rvOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/Equal.c b/security/nss/lib/pkix/src/RDNSequence/Equal.c new file mode 100644 index 000000000..fe0fa0f07 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * NSSPKIXRDNSequence_Equal + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +NSSPKIXRDNSequence_Equal +( + NSSPKIXRDNSequence *one, + NSSPKIXRDNSequence *two, + PRStatus *statusOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(one) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(two) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_Equal(one, two, statusOpt); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/FindRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/FindRelativeDistinguishedName.c new file mode 100644 index 000000000..cb04286d3 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/FindRelativeDistinguishedName.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 */ + +/* + * NSSPKIXRDNSequence_FindRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_PKIX_RDN + * 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 +NSSPKIXRDNSequence_FindRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + NSSPKIXRelativeDistinguishedName *rdn +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_FindRelativeDistinguishedName(rdnseq, rdn); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/GetRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/GetRelativeDistinguishedName.c new file mode 100644 index 000000000..9b152f4da --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/GetRelativeDistinguishedName.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 */ + +/* + * NSSPKIXRDNSequence_GetRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +NSSPKIXRDNSequence_GetRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + PRInt32 i, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_GetRelativeDistinguishedName(rdnseq, i, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/GetRelativeDistinguishedNameCount.c b/security/nss/lib/pkix/src/RDNSequence/GetRelativeDistinguishedNameCount.c new file mode 100644 index 000000000..05b5e89b4 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/GetRelativeDistinguishedNameCount.c @@ -0,0 +1,71 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXRDNSequence_GetRelativeDistinguishedNameCount + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * Nonnegative integer upon success + * -1 upon failure. + */ + +NSS_IMPLEMENT PRInt32 +NSSPKIXRDNSequence_GetRelativeDistinguishedNameCount +( + NSSPKIXRDNSequence *rdnseq +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return -1; + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_GetRelativeDistinguishedNameCount(rdnseq); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/GetRelativeDistinguishedNames.c b/security/nss/lib/pkix/src/RDNSequence/GetRelativeDistinguishedNames.c new file mode 100644 index 000000000..06d419bed --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/GetRelativeDistinguishedNames.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 */ + +/* + * NSSPKIXRDNSequence_GetRelativeDistinguishedNames + * + * This routine returns all of the relative distinguished names in the + * specified RDN Sequence. {...} If the array is allocated, or if the + * specified one has extra space, the array will be null-terminated. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_ARRAY_TOO_SMALL + * + * Return value: + * A valid pointer to an array of NSSPKIXRelativeDistinguishedName + * pointers upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName ** +NSSPKIXRDNSequence_GetRelativeDistinguishedNames +( + NSSPKIXRDNSequence *rdnseq, + NSSPKIXRelativeDistinguishedName *rvOpt[], + PRInt32 limit, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return (NSSPKIXRelativeDistinguishedName **)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyOpt(attribute) ) { + return (NSSPKIXRelativeDistinguishedName **)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_GetRelativeDistinguishedNames(rdnseq, rvOpt, limit, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/GetUTF8Encoding.c b/security/nss/lib/pkix/src/RDNSequence/GetUTF8Encoding.c new file mode 100644 index 000000000..4519a5ba4 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * NSSPKIXRDNSequence_GetUTF8Encoding + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSUTF8 pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSUTF8 * +NSSPKIXRDNSequence_GetUTF8Encoding +( + NSSPKIXRDNSequence *rdnseq, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_GetUTF8Encoding(rdnseq, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/InsertRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/InsertRelativeDistinguishedName.c new file mode 100644 index 000000000..433c2a315 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/InsertRelativeDistinguishedName.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 */ + +/* + * NSSPKIXRDNSequence_InsertRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRDNSequence_InsertRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + PRInt32 i, + NSSPKIXRelativeDistinguishedName *rdn +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_InsertRelativeDistinguishedName(rdnseq, i, rdn); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/MClear.c b/security/nss/lib/pkix/src/RDNSequence/MClear.c new file mode 100644 index 000000000..7df7eb099 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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_RDNSequence_Clear + * + * Wipes out cached data. + */ + +NSS_IMPLEMENT PRStatus +nss_pkix_RDNSequence_Clear +( + NSSPKIXRDNSequence *rdnseq +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( (NSSBER *)NULL != rdnseq->ber ) { + nss_ZFreeIf(rdnseq->ber->data); + nss_ZFreeIf(rdnseq->ber); + } + + if( (NSSDER *)NULL != rdnseq->der ) { + nss_ZFreeIf(rdnseq->der->data); + nss_ZFreeIf(rdnseq->der); + } + + nss_ZFreeIf(rdnseq->utf8); + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/MCount.c b/security/nss/lib/pkix/src/RDNSequence/MCount.c new file mode 100644 index 000000000..649721c9f --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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_RDNSequence_Count + */ + +NSS_IMPLEMENT void +nss_pkix_RDNSequence_Count +( + NSSPKIXRDNSequence *rdnseq +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return; + } +#endif /* NSSDEBUG */ + + PR_ASSERT((NSSPKIXRelativeDistinguishedName **)NULL != rdnseq->rdns); + if( (NSSPKIXRelativeDistinguishedName **)NULL == rdnseq->rdns ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + return PR_FAILURE; + } + + if( 0 == rdnseq->count ) { + PRUint32 i; + for( i = 0; i < 0xFFFFFFFF; i++ ) { + if( (NSSPKIXRelativeDistinguishedName *)NULL == rdnseq->rdns[i] ) { + break; + } + } + +#ifdef PEDANTIC + if( 0xFFFFFFFF == i ) { + return; + } +#endif /* PEDANTIC */ + + rdnseq->count = i; + } + + return; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/MVCreate.c b/security/nss/lib/pkix/src/RDNSequence/MVCreate.c new file mode 100644 index 000000000..caeb1995f --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/MVCreate.c @@ -0,0 +1,141 @@ +/* + * 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_RDNSequence_v_create + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +nss_pkix_RDNSequence_v_create +( + NSSArena *arenaOpt, + PRUint32 count, + va_list ap +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXRDNSequence *rv = (NSSPKIXRDNSequence *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRDNSequence *)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, NSSPKIXRDNSequence); + if( (NSSPKIXRDNSequence *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + rv->count = count; + + rv->rdns = nss_ZNEWARRAY(arena, NSSPKIXRelativeDistinguishedName *, count); + if( (NSSPKIXRelativeDistinguishedName **)NULL == rv->rdns ) { + goto loser; + } + + for( i = 0; i < count; i++ ) { + NSSPKIXRelativeDistinguishedName *v = (NSSPKIXRelativeDistinguishedName *) + va_arg(ap, NSSPKIXRelativeDistinguishedName *); + +#ifdef NSSDEBUG + /* + * It's okay to test this down here, since + * supposedly these have already been checked. + */ + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(v) ) { + goto loser; + } +#endif /* NSSDEBUG */ + + rv->rdns[i] = nssPKIXRelativeDistinguishedName_Duplicate(v, arena); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rv->rdns[i] ) { + goto loser; + } + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_RDNSequence_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 (NSSPKIXRDNSequence *)NULL; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PAppendRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/PAppendRelativeDistinguishedName.c new file mode 100644 index 000000000..9d1ea4875 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PAppendRelativeDistinguishedName.c @@ -0,0 +1,105 @@ +/* + * 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 */ + +/* + * nssPKIXRDNSequence_AppendRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRDNSequence_AppendRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + NSSPKIXRelativeDistinguishedName *rdn +) +{ + NSSPKIXRelativeDistinguishedName **na; + NSSPKIXRelativeDistinguishedName *dup; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( 0 == rdnseq->count ) { + nss_pkix_RDNSequence_Count(rdnseq); + } + +#ifdef PEDANTIC + if( 0 == rdnseq->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* PEDANTIC */ + + na = (NSSPKIXRelativeDistinguishedName **) + nss_ZRealloc(rdnseq->rdns, ((rdnseq->count+2) * + sizeof(NSSPKIXRelativeDistinguishedName *))); + if( (NSSPKIXRelativeDistinguishedName **)NULL == na ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + rdnseq->rdns = na; + + dup = nssPKIXRelativeDistinguishedName_Duplicate(rdn, rdnseq->arena); + if( (NSSPKIXRelativeDistinguishedName *)NULL == dup ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + na[ rdnseq->count++ ] = dup; + + return nss_pkix_RDNSequence_Clear(rdnseq); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PCreate.c b/security/nss/lib/pkix/src/RDNSequence/PCreate.c new file mode 100644 index 000000000..0fdc6848f --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * nssPKIXRDNSequence_Create + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_PKIX_RDN + * + * Return value: + * A valid pointer to an NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +nssPKIXRDNSequence_Create +( + NSSArena *arenaOpt, + NSSPKIXRelativeDistinguishedName *rdn1, + ... +) +{ + va_list ap; + NSSPKIXRDNSequence *rv; + PRUint32 count; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRDNSequence *)NULL; + } + } + + /* Is there a nonzero minimum number of RDNs required? */ + + { + va_start(ap, arenaOpt); + + while( 1 ) { + NSSPKIXRelativeDistinguishedName *rdn; + rdn = (NSSPKIXRelativeDistinguishedName *)va_arg(ap, NSSPKIXRelativeDistinguishedName *); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rdn ) { + break; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + va_end(ap); + return (NSSPKIXRDNSequence *)NULL; + } + } + + va_end(ap); + } +#endif /* NSSDEBUG */ + + va_start(ap, arenaOpt); + + for( count = 0; ; count++ ) { + NSSPKIXRelativeDistinguishedName *rdn; + rdn = (NSSPKIXRelativeDistinguishedName *)va_arg(ap, NSSPKIXRelativeDistinguishedName *); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rdn ) { + break; + } + +#ifdef PEDANTIC + if( count == 0xFFFFFFFF ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + va_end(ap); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* PEDANTIC */ + } + + va_end(ap); + + va_start(ap, arenaOpt); + rv = nss_pkix_RDNSequence_V_Create(arenaOpt, count, ap); + va_end(ap); + + return rv; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PCreateFromArray.c b/security/nss/lib/pkix/src/RDNSequence/PCreateFromArray.c new file mode 100644 index 000000000..0e244cb73 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXRDNSequence_CreateFromArray + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_INVALID_PKIX_RDN + * + * Return value: + * A valid pointer to an NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +nssPKIXRDNSequence_CreateFromArray +( + NSSArena *arenaOpt, + PRUint32 count, + NSSPKIXRelativeDistinguishedName *rdns[] +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXRDNSequence *rv = (NSSPKIXRDNSequence *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } + + { + PRUint32 i; + + for( i = 0; i < count; i++ ) { + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(&rdns[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, NSSPKIXRDNSequence); + if( (NSSPKIXRDNSequence *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + rv->count = count; + + rv->rdns = nss_ZNEWARRAY(arena, NSSPKIXRelativeDistinguishedName *, (count+1)); + if( (NSSPKIXRelativeDistinguishedName **)NULL == rv->rdns ) { + goto loser; + } + + for( i = 0; i < count; i++ ) { + NSSPKIXRelativeDistinguishedName *v = rdns[i]; + + rv->rdns[i] = nssPKIXRelativeDistinguishedName_Duplicate(v, arena); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rv->rdns[i] ) { + goto loser; + } + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_RDNSequence_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 (NSSPKIXRDNSequence *)NULL; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PCreateFromUTF8.c b/security/nss/lib/pkix/src/RDNSequence/PCreateFromUTF8.c new file mode 100644 index 000000000..196332665 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * nssPKIXRDNSequence_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 NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +nssPKIXRDNSequence_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *string +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXRDNSequence *rv = (NSSPKIXRDNSequence *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRDNSequence *)NULL; + } + } + + if( (NSSUTF8 *)NULL == string ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXRDNSequence *)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, NSSPKIXRDNSequence); + if( (NSSPKIXRDNSequence *)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_RDNSequence_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 (NSSPKIXRDNSequence *)NULL; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PDecode.c b/security/nss/lib/pkix/src/RDNSequence/PDecode.c new file mode 100644 index 000000000..557f5bc32 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PDecode.c @@ -0,0 +1,138 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXRDNSequence_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 NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +nssPKIXRDNSequence_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXRDNSequence *rv = (NSSPKIXRDNSequence *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXRDNSequence *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXRDNSequence *)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, NSSPKIXRDNSequence); + if( (NSSPKIXRDNSequence *)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, nssPKIXRDNSequence_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_RDNSequence_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 (NSSPKIXRDNSequence *)NULL; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PDestroy.c b/security/nss/lib/pkix/src/RDNSequence/PDestroy.c new file mode 100644 index 000000000..17cc846cf --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * nssPKIXRDNSequence_Destroy + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRDNSequence_Destroy +( + NSSPKIXRDNSequence *rdnseq +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + +#ifdef DEBUG + (void)nss_pkix_RDNSequence_remove_pointer(rdnseq); +#endif /* DEBUG */ + + if( PR_TRUE == rdnseq->i_allocated_arena ) { + return nssArena_Destroy(rdnseq->arena); + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PDuplicate.c b/security/nss/lib/pkix/src/RDNSequence/PDuplicate.c new file mode 100644 index 000000000..a57828692 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * nssPKIXRDNSequence_Duplicate + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXRDNSequence upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRDNSequence * +nssPKIXRDNSequence_Duplicate +( + NSSPKIXRDNSequence *rdnseq, + NSSArena *arenaOpt +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXRDNSequence *rv = (NSSPKIXRDNSequence *)NULL; + PRStatus status; + PRUint32 i; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyOpt(attribute) ) { + 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, NSSPKIXRDNSequence); + if( (NSSPKIXRDNSequence *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + + if( (NSSBER *)NULL != rdnseq->ber ) { + rv->ber = nssItem_Duplicate(rdnseq->ber, arena, (NSSItem *)NULL); + if( (NSSBER *)NULL == rv->ber ) { + goto loser; + } + } + + if( (NSSDER *)NULL != rdnseq->der ) { + rv->der = nssItem_Duplicate(rdnseq->der, arena, (NSSItem *)NULL); + if( (NSSDER *)NULL == rv->der ) { + goto loser; + } + } + + if( (NSSUTF8 *)NULL != rdnseq->utf8 ) { + rv->utf8 = nssUTF8_duplicate(rdnseq->utf8, arena); + if( (NSSUTF8 *)NULL == rv->utf8 ) { + goto loser; + } + } + + if( 0 == rdnseq->count ) { + nss_pkix_RDNSequence_Count(rdnseq); + } + +#ifdef PEDANTIC + if( 0 == rdnseq->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* PEDANTIC */ + + rv->count = rdnseq->count; + + rv->rdns = nss_ZNEWARRAY(arena, NSSPKIXRelativeDistinguishedName *, (rv->count+1)); + if( (NSSPKIXRelativeDistinguishedName **)NULL == rv->rdns ) { + goto loser; + } + + for( i = 0; i < count; i++ ) { + NSSPKIXRelativeDistinguishedName *v = rdnseq->rdns[i]; + + rv->rdns[i] = nssPKIXRelativeDistinguishedName_Duplicate(v, arena); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rv->rdns[i] ) { + goto loser; + } + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_RDNSequence_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 (NSSPKIXRDNSequence *)NULL; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PEncode.c b/security/nss/lib/pkix/src/RDNSequence/PEncode.c new file mode 100644 index 000000000..5700fa099 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PEncode.c @@ -0,0 +1,118 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXRDNSequence_Encode + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +nssPKIXRDNSequence_Encode +( + NSSPKIXRDNSequence *rdnseq, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + NSSBER *it; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + 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 != rdnseq->ber ) { + it = rdnseq->ber; + goto done; + } + /*FALLTHROUGH*/ + case NSSASN1DER: + if( (NSSDER *)NULL != rdnseq->der ) { + it = rdnseq->der; + goto done; + } + break; + default: + nss_SetError(NSS_ERROR_UNSUPPORTED_ENCODING); + return (NSSBER *)NULL; + } + + it = nssASN1_EncodeItem(rdnseq->arena, (NSSItem *)NULL, rdnseq, + nssPKIXRDNSequence_template, encoding); + if( (NSSBER *)NULL == it ) { + return (NSSBER *)NULL; + } + + switch( encoding ) { + case NSSASN1BER: + rdnseq->ber = it; + break; + case NSSASN1DER: + rdnseq->der = it; + break; + default: + PR_ASSERT(0); + break; + } + + done: + return nssItem_Duplicate(it, arenaOpt, rvOpt); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PEqual.c b/security/nss/lib/pkix/src/RDNSequence/PEqual.c new file mode 100644 index 000000000..a1dd5af53 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PEqual.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 */ + +/* + * nssPKIXRDNSequence_Equal + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +nssPKIXRDNSequence_Equal +( + NSSPKIXRDNSequence *one, + NSSPKIXRDNSequence *two, + PRStatus *statusOpt +) +{ + NSSPKIXRelativeDistinguishedName **a; + NSSPKIXRelativeDistinguishedName **b; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(one) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(two) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } +#endif /* NSSDEBUG */ + + if( ((NSSDER *)NULL != one->der) && ((NSSDER *)NULL != two->der) ) { + return nssItem_Equal(one->der, two->der, statusOpt); + } + + /* + * Since this is a sequence, the order is significant. + * So we just walk down both lists, comparing. + */ + + for( a = one->rdns, b = two->rdns; *a && *b; a++, b++ ) { + if( PR_FALSE == nssPKIXRelativeDistinguishedName_Equal(*a, *b, statusOpt) ) { + return PR_FALSE; + } + } + + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_SUCCESS; + } + + if( *a || *b ) { + return PR_FALSE; + } + + return PR_TRUE; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PFindRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/PFindRelativeDistinguishedName.c new file mode 100644 index 000000000..8064b9636 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PFindRelativeDistinguishedName.c @@ -0,0 +1,90 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXRDNSequence_FindRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_PKIX_RDN + * 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 +nssPKIXRDNSequence_FindRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + NSSPKIXRelativeDistinguishedName *rdn +) +{ + PRUint32 i; + NSSPKIXRelativeDistinguishedName **a; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + for( i = 0, a = rdnseq->rdns; *a; a++, (i > 0x7fffffff) || i++ ) { + if( PR_TRUE == nssPKIXRelativeDistinguishedName_Equal(*a, rdn) ) { + 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/RDNSequence/PGetRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/PGetRelativeDistinguishedName.c new file mode 100644 index 000000000..7ea20d259 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PGetRelativeDistinguishedName.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 */ + +/* + * nssPKIXRDNSequence_GetRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXRelativeDistinguishedName upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName * +nssPKIXRDNSequence_GetRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + PRInt32 i, + NSSArena *arenaOpt +) +{ + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyOpt(attribute) ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( 0 == rdnseq->count ) { + nss_pkix_RDNSequence_Count(rdnseq); + } + +#ifdef PEDANTIC + if( 0 == rdnseq->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* PEDANTIC */ + + if( (i < 0) || (i >= rdnseq->count) ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + return nssPKIXRelativeDistinguishedName_Duplicate(rdnseq->rdns[i], arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PGetRelativeDistinguishedNameCount.c b/security/nss/lib/pkix/src/RDNSequence/PGetRelativeDistinguishedNameCount.c new file mode 100644 index 000000000..a01077db1 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PGetRelativeDistinguishedNameCount.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 */ + +/* + * nssPKIXRDNSequence_GetRelativeDistinguishedNameCount + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * Nonnegative integer upon success + * -1 upon failure. + */ + +NSS_IMPLEMENT PRInt32 +nssPKIXRDNSequence_GetRelativeDistinguishedNameCount +( + NSSPKIXRDNSequence *rdnseq +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return -1; + } +#endif /* NSSDEBUG */ + + if( 0 == rdnseq->count ) { + nss_pkix_RDNSequence_Count(rdnseq); + } + +#ifdef PEDANTIC + if( 0 == rdnseq->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return -1; + } +#endif /* PEDANTIC */ + + if( rdnseq->count > 0x7fffffff ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return -1; + } + + return (PRInt32)(rdnseq->count); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PGetRelativeDistinguishedNames.c b/security/nss/lib/pkix/src/RDNSequence/PGetRelativeDistinguishedNames.c new file mode 100644 index 000000000..115480dfd --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PGetRelativeDistinguishedNames.c @@ -0,0 +1,135 @@ +/* + * 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 */ + +/* + * nssPKIXRDNSequence_GetRelativeDistinguishedNames + * + * This routine returns all of the relative distinguished names in the + * specified RDN Sequence. {...} If the array is allocated, or if the + * specified one has extra space, the array will be null-terminated. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_ARRAY_TOO_SMALL + * + * Return value: + * A valid pointer to an array of NSSPKIXRelativeDistinguishedName + * pointers upon success + * NULL upon failure. + */ + +NSS_IMPLEMENT NSSPKIXRelativeDistinguishedName ** +nssPKIXRDNSequence_GetRelativeDistinguishedNames +( + NSSPKIXRDNSequence *rdnseq, + NSSPKIXRelativeDistinguishedName *rvOpt[], + PRInt32 limit, + NSSArena *arenaOpt +) +{ + NSSPKIXRelativeDistinguishedName **rv = (NSSPKIXRelativeDistinguishedName **)NULL; + PRUint32 i; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return (NSSPKIXRelativeDistinguishedName **)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyOpt(attribute) ) { + return (NSSPKIXRelativeDistinguishedName **)NULL; + } + } +#endif /* NSSDEBUG */ + + if( 0 == rdnseq->count ) { + nss_pkix_RDNSequence_Count(rdnseq); + } + +#ifdef PEDANTIC + if( 0 == rdnseq->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName **)NULL; + } +#endif /* PEDANTIC */ + + if( (limit < rdnseq->count) && + !((0 == limit) && ((NSSPKIXRelativeDistinguishedName **)NULL == rvOpt)) ) { + nss_SetError(NSS_ERROR_ARRAY_TOO_SMALL); + return (NSSPKIXRelativeDistinguishedName **)NULL; + } + + limit = rdnseq->count; + if( (NSSPKIXRelativeDistinguishedName **)NULL == rvOpt ) { + rv = nss_ZNEWARRAY(arenaOpt, NSSPKIXRelativeDistinguishedName *, limit); + if( (NSSPKIXRelativeDistinguishedName **)NULL == rv ) { + return (NSSPKIXRelativeDistinguishedName **)NULL; + } + } else { + rv = rvOpt; + } + + for( i = 0; i < limit; i++ ) { + rv[i] = nssPKIXRelativedistinguishedName_Duplicate(rdnseq->rdns[i], arenaOpt); + if( (NSSPKIXRelativeDistinguishedName *)NULL == rv[i] ) { + goto loser; + } + } + + return rv; + + loser: + for( i = 0; i < limit; i++ ) { + NSSPKIXRelativeDistinguishedName *x = rv[i]; + if( (NSSPKIXRelativeDistinguishedName *)NULL == x ) { + break; + } + (void)nssPKIXRelativeDistinguishedName_Destroy(x); + } + + if( rv != rvOpt ) { + nss_ZFreeIf(rv); + } + + return (NSSPKIXRelativeDistinguishedName **)NULL; +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PGetUTF8Encoding.c b/security/nss/lib/pkix/src/RDNSequence/PGetUTF8Encoding.c new file mode 100644 index 000000000..2250bf960 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * nssPKIXRDNSequence_GetUTF8Encoding + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_ARENA + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSUTF8 pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSUTF8 * +nssPKIXRDNSequence_GetUTF8Encoding +( + NSSPKIXRDNSequence *rdnseq, + NSSArena *arenaOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( (NSSUTF8 *)NULL == rdnseq->utf8 ) { + /* xxx fgmr fill this in from pki1 implementation */ + } + + return nssUTF8_Duplicate(rdnseq->utf8, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PInsertRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/PInsertRelativeDistinguishedName.c new file mode 100644 index 000000000..213866694 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PInsertRelativeDistinguishedName.c @@ -0,0 +1,117 @@ +/* + * 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 */ + +/* + * nssPKIXRDNSequence_InsertRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRDNSequence_InsertRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + PRInt32 i, + NSSPKIXRelativeDistinguishedName *rdn +) +{ + NSSPKIXRelativeDistinguishedName **na; + NSSPKIXRelativeDistinguishedName *dup; + PRInt32 c; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( 0 == rdnseq->count ) { + nss_pkix_RDNSequence_Count(rdnseq); + } + +#ifdef PEDANTIC + if( 0 == rdnseq->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* PEDANTIC */ + + if( (i < 0) || (i >= rdnseq->count) ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + na = (NSSPKIXRelativeDistinguishedName **) + nss_ZRealloc(rdnseq->rdns, ((rdnseq->count+2) * + sizeof(NSSPKIXRelativeDistinguishedName *))); + if( (NSSPKIXRelativeDistinguishedName **)NULL == na ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + rdnseq->rdns = na; + + dup = nssPKIXRelativeDistinguishedName_Duplicate(rdn, rdnseq->arena); + if( (NSSPKIXRelativeDistinguishedName *)NULL == dup ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + for( c = rdnseq->count; c > i; c-- ) { + na[ c ] = na[ c-1 ]; + } + + na[ i ] = dup; + rdnseq->count++; + + return nss_pkix_RDNSequence_Clear(rdnseq); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PRemoveRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/PRemoveRelativeDistinguishedName.c new file mode 100644 index 000000000..447620c77 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PRemoveRelativeDistinguishedName.c @@ -0,0 +1,104 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXRDNSequence_RemoveRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRDNSequence_RemoveRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + PRInt32 i +) +{ + NSSPKIXRelativeDistinguishedName **na; + PRInt32 c; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( 0 == rdnseq->count ) { + nss_pkix_RDNSequence_Count(rdnseq); + } + +#ifdef PEDANTIC + if( 0 == rdnseq->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* PEDANTIC */ + + if( (i < 0) || (i >= rdnseq->count) ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + nssPKIXRelativeDistinguishedName_Destroy(rdnseq->rdns[i]); + + rdnseq->rdns[i] = rdnseq->rdns[ rdnseq->count ]; + rdnseq->rdns[ rdnseq->count ] = (NSSPKIXRelativeDistinguishedName *)NULL; + rdnseq->count--; + + na = (NSSPKIXRelativeDistinguishedName **) + nss_ZRealloc(rdnseq->rdns, ((rdnseq->count) * + sizeof(NSSPKIXRelativeDistinguishedName *))); + if( (NSSPKIXRelativeDistinguishedName **)NULL == na ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + rdnseq->rdns = na; + + return nss_pkix_RDNSequence_Clear(rdnseq); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PSetRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/PSetRelativeDistinguishedName.c new file mode 100644 index 000000000..5c8123266 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PSetRelativeDistinguishedName.c @@ -0,0 +1,103 @@ +/* + * 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 */ + +/* + * nssPKIXRDNSequence_SetRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRDNSequence_SetRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + PRInt32 i, + NSSPKIXRelativeDistinguishedName *rdn +) +{ + NSSPKIXRelativeDistinguishedName *dup; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( 0 == rdnseq->count ) { + nss_pkix_RDNSequence_Count(rdnseq); + } + +#ifdef PEDANTIC + if( 0 == rdnseq->count ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } +#endif /* PEDANTIC */ + + if( (i < 0) || (i >= rdnseq->count) ) { + nss_SetError(NSS_ERROR_VALUE_OUT_OF_RANGE); + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + dup = nssPKIXRelativeDistinguishedName_Duplicate(rdn, rdnseq->arena); + if( (NSSPKIXRelativeDistinguishedName *)NULL == dup ) { + return (NSSPKIXRelativeDistinguishedName *)NULL; + } + + nssPKIXRelativeDistinguishedName_Destroy(rdnseq->rdns[i]); + rdnseq->rdns[i] = dup; + + return nss_pkix_RDNSequence_Clear(rdnseq); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/PSetRelativeDistinguishedNames.c b/security/nss/lib/pkix/src/RDNSequence/PSetRelativeDistinguishedNames.c new file mode 100644 index 000000000..b0320a4b7 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/PSetRelativeDistinguishedNames.c @@ -0,0 +1,153 @@ +/* + * 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 */ + +/* + * nssPKIXRDNSequence_SetRelativeDistinguishedNames + * + * -- fgmr comments -- + * If the array pointer itself is null, the set is considered empty. + * If the count is zero but the pointer nonnull, the array will be + * assumed to be null-terminated. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_PKIX_RDN + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +nssPKIXRDNSequence_SetRelativeDistinguishedNames +( + NSSPKIXRDNSequence *rdnseq, + NSSPKIXRelativeDistinguishedName *rdns[], + PRInt32 countOpt +) +{ + NSSPKIXRelativeDistinguishedName **ip; + NSSPKIXRelativeDistinguishedName **newarray; + PRUint32 i; + nssArenaMark *mark; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } + + if( (NSSPKIXRelativeDistinguishedName **)NULL == rdns ) { + nss_SetError(NSS_ERROR_INVALID_POINTER); + return PR_FAILURE; + } + + { + PRUint32 i, count; + + if( 0 == countOpt ) { + for( i = 0; i < 0x80000000; i++ ) { + if( (NSSPKIXRelativeDistinguishedName *)NULL == rdns[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 != nssPKIXRelativeDistinguishedName_verifyPointer(rdns[i]) ) { + return PR_FAILURE; + } + } + } +#endif /* NSSDEBUG */ + + mark = nssArena_Mark(rdnseq->mark); + if( (nssArenaMark *)NULL == mark ) { + return PR_FAILURE; + } + + newarray = nss_ZNEWARRAY(rdnseq->arena, NSSPKIXRelativeDistinguishedName *, countOpt); + if( (NSSPKIXRelativeDistinguishedName **)NULL == newarray ) { + goto loser; + } + + for( i = 0; i < countOpt; i++ ) { + newarray[i] = nssPKIXRelativeDistinguishedName_Duplicate(rdns[i], rdnseq->arena); + if( (NSSPKIXRelativeDistinguishedName *)NULL == newarray[i] ) { + goto loser; + } + } + + for( i = 0; i < rdnseq->count; i++ ) { + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_Destroy(rdnseq->rdns[i]) ) { + goto loser; + } + } + + nss_ZFreeIf(rdnseq->rdns); + + rdnseq->count = countOpt; + rdnseq->rdns = newarray; + + (void)nss_pkix_RDNSequence_Clear(rdnseq); + + return nssArena_Unmark(rdnseq->arena, mark); + + loser: + (void)nssArena_Release(a->arena, mark); + return PR_FAILURE; +} + diff --git a/security/nss/lib/pkix/src/RDNSequence/RemoveRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/RemoveRelativeDistinguishedName.c new file mode 100644 index 000000000..141ab7f37 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/RemoveRelativeDistinguishedName.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 */ + +/* + * NSSPKIXRDNSequence_RemoveRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRDNSequence_RemoveRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + PRInt32 i +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_RemoveRelativeDistinguishedName(rdnseq, i); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/SetRelativeDistinguishedName.c b/security/nss/lib/pkix/src/RDNSequence/SetRelativeDistinguishedName.c new file mode 100644 index 000000000..7484eb55d --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/SetRelativeDistinguishedName.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 */ + +/* + * NSSPKIXRDNSequence_SetRelativeDistinguishedName + * + * -- fgmr comments -- + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_VALUE_OUT_OF_RANGE + * NSS_ERROR_INVALID_PKIX_RDN + * NSS_ERROR_NO_MEMORY + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRDNSequence_SetRelativeDistinguishedName +( + NSSPKIXRDNSequence *rdnseq, + PRInt32 i, + NSSPKIXRelativeDistinguishedName *rdn +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } + + if( PR_SUCCESS != nssPKIXRelativeDistinguishedName_verifyPointer(rdn) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_SetRelativeDistinguishedName(rdnseq, i, rdn); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/SetRelativeDistinguishedNames.c b/security/nss/lib/pkix/src/RDNSequence/SetRelativeDistinguishedNames.c new file mode 100644 index 000000000..40e7c8247 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/SetRelativeDistinguishedNames.c @@ -0,0 +1,115 @@ +/* + * 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 */ + +/* + * NSSPKIXRDNSequence_SetRelativeDistinguishedNames + * + * -- fgmr comments -- + * If the array pointer itself is null, the set is considered empty. + * If the count is zero but the pointer nonnull, the array will be + * assumed to be null-terminated. + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_PKIX_RDN_SEQUENCE + * NSS_ERROR_INVALID_PKIX_RDN + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT PRStatus +NSSPKIXRDNSequence_SetRelativeDistinguishedNames +( + NSSPKIXRDNSequence *rdnseq, + NSSPKIXRelativeDistinguishedName *rdns[], + PRInt32 countOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXRDNSequence_verifyPointer(rdnseq) ) { + return PR_FAILURE; + } + + if( (NSSPKIXRelativeDistinguishedName **)NULL == rdns ) { + nss_SetError(NSS_ERROR_INVALID_POINTER); + return PR_FAILURE; + } + + { + PRUint32 i, count; + + if( 0 == countOpt ) { + for( i = 0; i < 0x80000000; i++ ) { + if( (NSSPKIXRelativeDistinguishedName *)NULL == rdns[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 != nssPKIXRelativeDistinguishedName_verifyPointer(rdns[i]) ) { + return PR_FAILURE; + } + } + } +#endif /* DEBUG */ + + return nssPKIXRDNSequence_SetRelativeDistinguishedNames(rdnseq, rdns, countOpt); +} diff --git a/security/nss/lib/pkix/src/RDNSequence/template.c b/security/nss/lib/pkix/src/RDNSequence/template.c new file mode 100644 index 000000000..ff5bbc0ba --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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 */ + +/* + * nssPKIXRDNSequence_template + * + */ + +const nssASN1Template nssPKIXRDNSequence_template[] = { + { nssASN1_SEQUENCE_OF, offsetof(NSSPKIXRDNSequence, rdns), + nssPKIXRelativeDistinguishedName_template }, + { 0 } +}; diff --git a/security/nss/lib/pkix/src/RDNSequence/verifyPointer.c b/security/nss/lib/pkix/src/RDNSequence/verifyPointer.c new file mode 100644 index 000000000..47a53a5c4 --- /dev/null +++ b/security/nss/lib/pkix/src/RDNSequence/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_rdnseq_pointer_tracker; + +/* + * nss_pkix_RDNSequence_add_pointer + * + * This method is only present in debug builds. + * + * This module-private routine adds an NSSPKIXRDNSequence 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_RDNSequence_add_pointer +( + const NSSPKIXRDNSequence *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_rdnseq_pointer_tracker); + if( PR_SUCCESS != rv ) { + return rv; + } + + rv = nssPointerTracker_add(&pkix_rdnseq_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(arena, + nss_pkix_RDNSequence_remove_pointer, p); + if( PR_SUCCESS != rv ) { + (void)nss_pkix_RDNSequence_remove_pointer(p); + return rv; + } + +#ifdef NSSDEBUG + { + NSSPKIXRelativeDistinguishedName *r; + + for( r = p->rdns; *r; r++ ) { + if( PR_SUCCESS != nss_pkix_RelativeDistinguishedName_add_pointer(*r) ) { + (void)nss_pkix_RDNSequence_remove_pointer(p); + return PR_FAILURE; + } + } + } +#endif /* NSSDEBUG */ + + return PR_SUCCESS; +} + +/* + * nss_pkix_RDNSequence_remove_pointer + * + * This method is only present in debug builds. + * + * This module-private routine removes a valid NSSPKIXRDNSequence + * 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_RDNSequence_remove_pointer +( + const NSSPKIXRDNSequence *p +) +{ + PRStatus rv; + +#ifdef NSSDEBUG + { + NSSPKIXRelativeDistinguishedName *r; + + for( r = p->rdns; *r; r++ ) { + (void)nss_pkix_RelativeDistinguishedName_remove_pointer(*r); + } + } +#endif /* NSSDEBUG */ + + rv = nssPointerTracker_remove(&pkix_rdnseq_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + } + + /* + * nssArena_deregisterDestructor(p->arena, + * nss_pkix_RDNSequence_remove_pointer, p); + */ + + return rv; +} + +/* + * nssPKIXRDNSequence_verifyPointer + * + * This method is only present in debug builds. + * + * If the specified pointer is a valid pointer to an NSSPKIXRDNSequence + * 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 +nssPKIXRDNSequence_verifyPointer +( + NSSPKIXRDNSequence *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_rdnseq_pointer_tracker); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + rv = nssPointerTracker_verify(&pkix_rdnseq_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_ATTRIBUTE); + return PR_FAILURE; + } + + return PR_SUCCESS; +} + +#endif /* DEBUG */ + 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 */ + diff --git a/security/nss/lib/pkix/src/Time/Compare.c b/security/nss/lib/pkix/src/Time/Compare.c new file mode 100644 index 000000000..6a125d6c6 --- /dev/null +++ b/security/nss/lib/pkix/src/Time/Compare.c @@ -0,0 +1,75 @@ +/* + * 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 */ + +/* + * NSSPKIXTime_Compare + * + * Usual result: -1, 0, 1 + * Returns 0 on error + */ + +NSS_IMPLEMENT PRInt32 +NSSPKIXTime_Compare +( + NSSPKIXTime *time1, + NSSPKIXTime *tiem2, + PRStatus *statusOpt +) + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time1) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return 0; + } + + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time2) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return 0; + } +#endif /* DEBUG */ + + return nssPKIXTime_Compare(time1, time2, statusOpt); +} diff --git a/security/nss/lib/pkix/src/Time/CreateFromPRTime.c b/security/nss/lib/pkix/src/Time/CreateFromPRTime.c new file mode 100644 index 000000000..909adb14e --- /dev/null +++ b/security/nss/lib/pkix/src/Time/CreateFromPRTime.c @@ -0,0 +1,65 @@ +/* + * 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 */ + +/* + * NSSPKIXTime_CreateFromPRTime + * + */ + +NSS_IMPLEMENT NSSPKIXTime * +NSSPKIXTime_CreateFromPRTime +( + NSSArena *arenaOpt, + PRTime prTime +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXTime *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXTime_CreateFromPRTime(arenaOpt, prTime); +} diff --git a/security/nss/lib/pkix/src/Time/CreateFromUTF8.c b/security/nss/lib/pkix/src/Time/CreateFromUTF8.c new file mode 100644 index 000000000..469741ac6 --- /dev/null +++ b/security/nss/lib/pkix/src/Time/CreateFromUTF8.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 */ + +/* + * NSSPKIXTime_CreateFromUTF8 + * + */ + +NSS_EXTERN NSSPKIXTime * +NSSPKIXTime_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *utf8 +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXTime *)NULL; + } + } + + if( (NSSUTF8 *)NULL == utf8 ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXTime *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXTime_CreateFromUTF8(arenaOpt, utf8); +} diff --git a/security/nss/lib/pkix/src/Time/Decode.c b/security/nss/lib/pkix/src/Time/Decode.c new file mode 100644 index 000000000..948dc0b93 --- /dev/null +++ b/security/nss/lib/pkix/src/Time/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 */ + +/* + * NSSPKIXTime_Decode + * + * + * + * 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 NSSPKIXTime upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXTime * +NSSPKIXTime_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXTime *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXTime *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXTime_Decode(arenaOpt, ber); +} diff --git a/security/nss/lib/pkix/src/Time/Destroy.c b/security/nss/lib/pkix/src/Time/Destroy.c new file mode 100644 index 000000000..d694850ef --- /dev/null +++ b/security/nss/lib/pkix/src/Time/Destroy.c @@ -0,0 +1,62 @@ +/* + * 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 */ + +/* + * NSSPKIXTime_Destroy + * + */ + +NSS_IMPLEMENT PR_STATUS +NSSPKIXTime_Destroy +( + NSSPKIXTime *time +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time) ) { + return PR_FAILURE; + } +#endif /* DEBUG */ + + return nssPKIXTime_Destroy(time); +} diff --git a/security/nss/lib/pkix/src/Time/Duplicate.c b/security/nss/lib/pkix/src/Time/Duplicate.c new file mode 100644 index 000000000..dee6f61e9 --- /dev/null +++ b/security/nss/lib/pkix/src/Time/Duplicate.c @@ -0,0 +1,69 @@ +/* + * 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 */ + +/* + * NSSPKIXTime_Duplicate + * + */ + +NSS_IMPLEMENT NSSPKIXTime * +NSSPKXITime_Duplicate +( + NSSPKIXTime *time, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time) ) { + return (NSSPKXITime *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXTime *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXTime_Duplicate(time, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Time/Encode.c b/security/nss/lib/pkix/src/Time/Encode.c new file mode 100644 index 000000000..9063e4f3a --- /dev/null +++ b/security/nss/lib/pkix/src/Time/Encode.c @@ -0,0 +1,71 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXTime_Encode + * + */ + +NSS_IMPLEMENT NSSBER * +NSSPKIXTime_Encode +( + NSSPKIXTime *time, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXTime_Encode(time, encoding, rvOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Time/Equal.c b/security/nss/lib/pkix/src/Time/Equal.c new file mode 100644 index 000000000..4ed05acd5 --- /dev/null +++ b/security/nss/lib/pkix/src/Time/Equal.c @@ -0,0 +1,74 @@ +/* + * 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 */ + +/* + * NSSPKIXTime_Equal + * + */ + +NSS_IMPLEMENT PRBool +NSSPKXITime_Equal +( + NSSPKXITime *time1, + NSSPKXITime *time2, + PRStatus *statusOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time1) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time2) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } +#endif /* DEBUG */ + + return nssPKIXTime_Equal(time1, time2, statusOpt); +} diff --git a/security/nss/lib/pkix/src/Time/GetPRTime.c b/security/nss/lib/pkix/src/Time/GetPRTime.c new file mode 100644 index 000000000..5871a482d --- /dev/null +++ b/security/nss/lib/pkix/src/Time/GetPRTime.c @@ -0,0 +1,64 @@ +/* + * 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 */ + +/* + * NSSPKIXTime_GetPRTime + * + * Returns a zero on error + */ + +NSS_IMPLEMENT PRTime +NSSPKIXTime_GetPRTime +( + NSSPKIXTime *time, + PRStatus *statusOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time) ) { + return (PRTime)0; + } +#endif /* DEBUG */ + + return nssPKIXTime_GetPRTime(time, statusOpt); +} diff --git a/security/nss/lib/pkix/src/Time/GetUTF8Encoding.c b/security/nss/lib/pkix/src/Time/GetUTF8Encoding.c new file mode 100644 index 000000000..7fc383b81 --- /dev/null +++ b/security/nss/lib/pkix/src/Time/GetUTF8Encoding.c @@ -0,0 +1,69 @@ +/* + * 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 */ + +/* + * NSSPKIXTime_GetUTF8Encoding + * + */ + +NSS_IMPLEMENT NSSUTF8 * +NSSPKXITime_GetUTF8Encoding +( + NSSPKIXTime *time, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXTime_GetUTF8Encoding(time, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/Time/PCreateFromPRTime.c b/security/nss/lib/pkix/src/Time/PCreateFromPRTime.c new file mode 100644 index 000000000..13805e65d --- /dev/null +++ b/security/nss/lib/pkix/src/Time/PCreateFromPRTime.c @@ -0,0 +1,117 @@ +/* + * 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 */ + +/* + * nssPKIXTime_CreateFromPRTime + * + */ + +NSS_IMPLEMENT NSSPKIXTime * +nssPKIXTime_CreateFromPRTime +( + NSSArena *arenaOpt, + PRTime prTime +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXTime *rv = (NSSPKIXTime *)NULL; + PRStatus status; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXTime *)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, NSSPKIXTime); + if( (NSSPKIXTime *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + + rv->prTime = prTime; + rv->prTimeValid = PR_TRUE; + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_Time_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 (NSSPKIXTime *)NULL; +} diff --git a/security/nss/lib/pkix/src/Time/PCreateFromUTF8.c b/security/nss/lib/pkix/src/Time/PCreateFromUTF8.c new file mode 100644 index 000000000..1a15639ed --- /dev/null +++ b/security/nss/lib/pkix/src/Time/PCreateFromUTF8.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 */ + +/* + * nssPKIXTime_CreateFromUTF8 + * + */ + +NSS_IMPLEMENT NSSPKIXTime * +nssPKIXTime_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *utf8 +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXTime *rv = (NSSPKIXTime *)NULL; + PRStatus status; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXTime *)NULL; + } + } + + if( (NSSUTF8 *)NULL == utf8 ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXTime *)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, NSSPKIXTime); + if( (NSSPKIXTime *)NULL == rv ) { + goto loser; + } + + rv->arena = arena; + rv->i_allocated_arena = arena_allocated; + + /* fgmr base on nspr's pl implementation? */ + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arena, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_Time_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 (NSSPKIXTime *)NULL; +} diff --git a/security/nss/lib/pkix/src/Time/PDecode.c b/security/nss/lib/pkix/src/Time/PDecode.c new file mode 100644 index 000000000..385665468 --- /dev/null +++ b/security/nss/lib/pkix/src/Time/PDecode.c @@ -0,0 +1,137 @@ +/* + * 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 */ + +/* + * nssPKIXTime_Decode + * + * + * + * 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 NSSPKIXTime upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXTime * +nssPKIXTime_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + NSSArena *arena; + PRBool arena_allocated = PR_FALSE; + nssArenaMark *mark = (nssArenaMark *)NULL; + NSSPKIXTime *rv = (NSSPKIXTime *)NULL; + PRStatus status; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXTime *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXTime *)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, NSSPKIXTime); + if( (NSSPKIXTime *)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, nssPKIXTime_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_Time_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 (NSSPKIXTime *)NULL; +} diff --git a/security/nss/lib/pkix/src/Time/PDestroy.c b/security/nss/lib/pkix/src/Time/PDestroy.c new file mode 100644 index 000000000..973974b51 --- /dev/null +++ b/security/nss/lib/pkix/src/Time/PDestroy.c @@ -0,0 +1,68 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXTime_Destroy + * + */ + +NSS_IMPLEMENT PR_STATUS +nssPKIXTime_Destroy +( + NSSPKIXTime *time +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + +#ifdef DEBUG + (void)nss_pkix_Time_remove_pointer(time); +#endif /* DEBUG */ + + if( PR_TRUE == time->i_allocated_arena ) { + return nssArena_Destroy(time->arena); + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/Time/PEncode.c b/security/nss/lib/pkix/src/Time/PEncode.c new file mode 100644 index 000000000..8904fac50 --- /dev/null +++ b/security/nss/lib/pkix/src/Time/PEncode.c @@ -0,0 +1,66 @@ +/* + * 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 */ + +/* + * nssPKIXTime_Encode + * + */ + +NSS_IMPLEMENT NSSBER * +nssPKIXTime_Encode +( + NSSPKIXTime *time, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXTime_verifyPointer(time) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* NSSDEBUG */ diff --git a/security/nss/lib/pkix/src/Time/template.c b/security/nss/lib/pkix/src/Time/template.c new file mode 100644 index 000000000..38c4f3c78 --- /dev/null +++ b/security/nss/lib/pkix/src/Time/template.c @@ -0,0 +1,54 @@ +/* + * 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 */ + +/* + * nssPKIXTime_template + * + */ + +const nssASN1Template nssPKIXTime_template[] = { + { nssASN1_INLINE, offsetof(NSSPKIXTime, asn1item), + nssASN1Template_Any, sizeof(NSSPKIXTime) } +}; diff --git a/security/nss/lib/pkix/src/X520Name/CreateFromUTF8.c b/security/nss/lib/pkix/src/X520Name/CreateFromUTF8.c new file mode 100644 index 000000000..84df20054 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/CreateFromUTF8.c @@ -0,0 +1,105 @@ +/* + * 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 */ + +/* + * NSSPKIXX520Name_CreateFromUTF8 + * + * { basically just enforces the length limit } + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_STRING + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXX520Name upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXX520Name * +NSSPKIXX520Name_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *utf8 +) +{ + PRStatus status = PR_SUCCESS; + PRUint32 length; + nss_ClearErrorStack(); + + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXX520Name *)NULL; + } + } + + if( (NSSUTF8 *)NULL == utf8 ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXX520Name *)NULL; + } +#endif /* DEBUG */ + + length = nssUTF8_Length(utf8, &status); + if( PR_SUCCESS != status ) { + if( NSS_ERROR_VALUE_TOO_LARGE == NSS_GetError() ) { + nss_SetError(NSS_ERROR_STRING_TOO_LONG); + } + return (NSSPKIXX520Name *)NULL; + } + + if( (length < 1 ) || (length > NSSPKIXX520Name_MAXIMUM_LENGTH) ) { + nss_SetError(NSS_ERROR_STRING_TOO_LONG); + } + + return nssPKIXX520Name_CreateFromUTF8(arenaOpt, utf8); +} + +/* + * NSSPKIXX520Name_MAXIMUM_LENGTH + * + * From RFC 2459: + * + * ub-name INTEGER ::= 32768 + */ + +const PRUint32 NSSPKIXX520Name_MAXIMUM_LENGTH = 32768; diff --git a/security/nss/lib/pkix/src/X520Name/Decode.c b/security/nss/lib/pkix/src/X520Name/Decode.c new file mode 100644 index 000000000..ac59d5598 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/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 */ + +/* + * NSSPKIXX520Name_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 NSSPKIXX520Name upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXX520Name * +NSSPKIXX520Name_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXAttribute *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXX520Name_Decode(arenaOpt, ber); +} diff --git a/security/nss/lib/pkix/src/X520Name/Destroy.c b/security/nss/lib/pkix/src/X520Name/Destroy.c new file mode 100644 index 000000000..49037d3b4 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/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 */ + +/* + * NSSPKIXX520Name_Destroy + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_X520_NAME + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_IMPLEMENT NSSDER * +NSSPKIXX520Name_Destroy +( + NSSPKIXX520Name *name +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name) ) { + return (NSSDER *)NULL; + } +#endif /* DEBUG */ + + return nssPKIXX520Name_Destroy(name); +} diff --git a/security/nss/lib/pkix/src/X520Name/Duplicate.c b/security/nss/lib/pkix/src/X520Name/Duplicate.c new file mode 100644 index 000000000..bcb4b5a2b --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/Duplicate.c @@ -0,0 +1,79 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * NSSPKIXX520Name_Duplicate + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_X520_NAME + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXX520Name upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXX520Name * +NSSPKIXX520Name_Duplicate +( + NSSPKIXX520Name *name, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name) ) { + return (NSSPKIXAttribute *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXX520Name_Duplicate(name, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/X520Name/Encode.c b/security/nss/lib/pkix/src/X520Name/Encode.c new file mode 100644 index 000000000..83cfd5442 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/Encode.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 */ + +/* + * NSSPKIXX520Name_Encode + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_X520_NAME + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +NSSPKIXX520Name_Encode +( + NSSPKIXX520Name *name, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXX520Name_Encode(name, encoding, rvOpt, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/X520Name/Equal.c b/security/nss/lib/pkix/src/X520Name/Equal.c new file mode 100644 index 000000000..75842e8f5 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/Equal.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 */ + +/* + * NSSPKIXX520Name_Equal + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_X520_NAME + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +NSSPKIXX520Name_Equal +( + NSSPKIXX520Name *name1, + NSSPKIXX520Name *name2, + PRStatus *statusOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name1) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } + + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name2) ) { + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + return PR_FALSE; + } +#endif /* DEBUG */ + + return nssPKIXX520Name_Equal(name1, name2, statusOpt); +} diff --git a/security/nss/lib/pkix/src/X520Name/GetUTF8Encoding.c b/security/nss/lib/pkix/src/X520Name/GetUTF8Encoding.c new file mode 100644 index 000000000..2e42124eb --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/GetUTF8Encoding.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 */ + +/* + * NSSPKIXX520Name_GetUTF8Encoding + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_X520_NAME + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSDER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSUTF8 * +NSSPKIXX520Name_GetUTF8Encoding +( + NSSPKIXX520Name *name, + NSSArena *arenaOpt +) +{ + nss_ClearErrorStack(); + +#ifdef DEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* DEBUG */ + + return nssPKIXX520Name_GetUTF8Encoding(name, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/X520Name/MDoUTF8.c b/security/nss/lib/pkix/src/X520Name/MDoUTF8.c new file mode 100644 index 000000000..69cbf691e --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/MDoUTF8.c @@ -0,0 +1,97 @@ +/* + * 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_X520Name_DoUTF8 + * + */ + +NSS_IMPLEMENT PR_STATUS +nss_pkix_X520Name_DoUTF8 +( + NSSPKIXX520Name *name +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( (NSSUTF8 *)NULL == name->utf8 ) { + PRUint8 tag = (*(PRUint8 *)name->string.data) & nssASN1_TAG_MASK; + nssStringType type; + void *data = (void *)&((PRUint8 *)name->string.data)[1]; + PRUint32 size = name->string.size-1; + + switch( tag ) { + case nssASN1_TELETEX_STRING: + type = nssStringType_TeletexString; + break; + case nssASN1_PRINTABLE_STRING: + type = nssStringType_PrintableString; + break; + case nssASN1_UNIVERSAL_STRING: + type = nssStringType_UniversalString; + break; + case nssASN1_BMP_STRING: + type = nssStringType_BMPString; + break; + case nssASN1_UTF8_STRING: + type = nssStringType_UTF8String; + break; + default: + nss_SetError(NSS_ERROR_INVALID_BER); + return PR_FAILURE; + } + + name->utf8 = nssUTF8_Create(arenaOpt, type, data, size); + if( (NSSUTF8 *)NULL == name->utf8 ) { + return PR_FAILURE; + } + + if( nssASN1_PRINTABLE_STRING == tag ) { + name->wasPrintable = PR_TRUE; + } + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/X520Name/PCreate.c b/security/nss/lib/pkix/src/X520Name/PCreate.c new file mode 100644 index 000000000..c507a8f75 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/PCreate.c @@ -0,0 +1,169 @@ +/* + * 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 */ + +/* + * nssPKIXX520Name_Create + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_STRING_TYPE + * NSS_ERROR_INVALID_ITEM + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid pointer to an NSSPKIXX520Name upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXX520Name * +nssPKIXX520Name_Create +( + NSSArena *arenaOpt, + nssStringType type, + NSSItem *data +) +{ + NSSPKIXX520Name *rv = (NSSPKIXX520Name *)NULL; + nssArenaMark *mark = (nssArenaMark *)NULL; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXX520Name *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(data) ) { + return (NSSPKIXX520Name *)NULL; + } +#endif /* NSSDEBUG */ + + switch( type ) { + case nssStringType_TeletexString: + case nssStringType_PrintableString: + case nssStringType_UniversalString: + case nssStringType_UTF8String: + case nssStringType_BMPString: + break; + default: + nss_SetError(NSS_ERROR_INVALID_STRING_TYPE); + goto loser; + } + + if( (NSSArena *)NULL != arenaOpt ) { + mark = nssArena_Mark(arenaOpt); + if( (nssArenaMark *)NULL == mark ) { + goto loser; + } + } + + rv = nss_ZNEW(arenaOpt, NSSPKIXX520Name); + if( (NSSPKIXX520Name *)NULL == rv ) { + goto loser; + } + + rv->utf8 = nssUTF8_Create(arenaOpt, type, data->data, data->size); + if( (NSSUTF8 *)NULL == rv->utf8 ) { + goto loser; + } + + if( nssStringType_PrintableString == type ) { + rv->wasPrintable = PR_TRUE; + } + + rv->der = nssUTF8_GetDEREncoding(arenaOpt, type, rv->utf8); + if( (NSSDER *)NULL == rv->der ) { + goto loser; + } + + rv->string.size = rv->der->size; + rv->string.data = nss_ZAlloc(arenaOpt, rv->string.size); + if( (void *)NULL == rv->string.data ) { + goto loser; + } + + (void)nsslibc_memcpy(rv->string.data, rv->der->data, rv->string.size); + + if( (NSSArena *)NULL != arenaOpt ) { + rv->inArena = PR_TRUE; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arenaOpt, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_X520Name_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != nssArena_registerDestructor(arena, + nss_pkix_X520Name_remove_pointer, rv) ) { + (void)nss_pkix_X520Name_remove_pointer(rv); + goto loser; + } +#endif /* DEBUG */ + + return rv; + + loser: + if( (nssArenaMark *)NULL != mark ) { + (void)nssArena_Release(arenaOpt, mark); + } + + if( (NSSArena *)NULL == arenaOpt ) { + if( (NSSPKIXX520Name *)NULL != rv ) { + if( (NSSDER *)NULL != rv->der ) { + nss_ZFreeIf(rv->der->data); + nss_ZFreeIf(rv->der); + } + + nss_ZFreeIf(rv->string.data); + nss_ZFreeIf(rv->utf8); + nss_ZFreeIf(rv); + } + } + + return (NSSPKIXX520Name *)NULL; +} diff --git a/security/nss/lib/pkix/src/X520Name/PCreateFromUTF8.c b/security/nss/lib/pkix/src/X520Name/PCreateFromUTF8.c new file mode 100644 index 000000000..0459f8c51 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/PCreateFromUTF8.c @@ -0,0 +1,164 @@ +/* + * 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 */ + +/* + * nssPKIXX520Name_CreateFromUTF8 + * + * { basically just enforces the length limit } + * + * 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 NSSPKIXX520Name upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXX520Name * +nssPKIXX520Name_CreateFromUTF8 +( + NSSArena *arenaOpt, + NSSUTF8 *utf8 +) +{ + NSSPKIXX520Name *rv = (NSSPKIXX520Name *)NULL; + nssArenaMark *mark = (nssArenaMark *)NULL; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXX520Name *)NULL; + } + } + + if( (NSSUTF8 *)NULL == utf8 ) { + nss_SetError(NSS_ERROR_INVALID_STRING); + return (NSSPKIXX520Name *)NULL; + } +#endif /* NSSDEBUG */ + + if( (NSSArena *)NULL != arenaOpt ) { + mark = nssArena_Mark(arenaOpt); + if( (nssArenaMark *)NULL == mark ) { + goto loser; + } + } + + rv = nss_ZNEW(arenaOpt, NSSPKIXX520Name); + if( (NSSPKIXX520Name *)NULL == rv ) { + goto loser; + } + + rv->utf8 = nssUTF8_Duplicate(utf8, arenaOpt); + if( (NSSUTF8 *)NULL == rv->utf8 ) { + goto loser; + } + + /* + * RFC 2459 states (s. 4.1.2.4) that certificates issued after + * 2003-12-31 MUST encode strings as UTF8Strings, and until + * then they may be encoded as PrintableStrings, BMPStrings, + * or UTF8Strings (when the character sets allow). However, it + * specifically notes that even before 2003-12-31, strings may + * be encoded as UTF8Strings. So unless something important + * breaks, I'll do UTF8Strings. + */ + + rv->der = nssUTF8_GetDEREncoding(arenaOpt, nssStringType_UTF8String, + utf8); + if( (NSSDER *)NULL == rv->der ) { + goto loser; + } + + rv->string.size = rv->der->size; + rv->string.data = nss_ZAlloc(arenaOpt, rv->string.size); + if( (void *)NULL == rv->string.data ) { + goto loser; + } + + (void)nsslibc_memcpy(rv->string.data, rv->der->size, rv->string.size); + + if( (NSSArena *)NULL != arenaOpt ) { + rv->inArena = PR_TRUE; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arenaOpt, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_X520Name_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != nssArena_registerDestructor(arena, + nss_pkix_X520Name_remove_pointer, rv) ) { + (void)nss_pkix_X520Name_remove_pointer(rv); + goto loser; + } +#endif /* DEBUG */ + + return rv; + + loser: + if( (nssArenaMark *)NULL != mark ) { + (void)nssArena_Release(arenaOpt, mark); + } + + if( (NSSArena *)NULL == arenaOpt ) { + if( (NSSPKIXX520Name *)NULL != rv ) { + if( (NSSDER *)NULL != rv->der ) { + nss_ZFreeIf(rv->der->data); + nss_ZFreeIf(rv->der); + } + + nss_ZFreeIf(rv->string.data); + nss_ZFreeIf(rv->utf8); + nss_ZFreeIf(rv); + } + } + + return (NSSPKIXX520Name *)NULL; +} diff --git a/security/nss/lib/pkix/src/X520Name/PDecode.c b/security/nss/lib/pkix/src/X520Name/PDecode.c new file mode 100644 index 000000000..8228c8db4 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/PDecode.c @@ -0,0 +1,135 @@ +/* + * 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 */ + +/* + * nssPKIXX520Name_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 NSSPKIXX520Name upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXX520Name * +nssPKIXX520Name_Decode +( + NSSArena *arenaOpt, + NSSBER *ber +) +{ + NSSPKIXX520Name *rv = (NSSPKIXX520Name *)NULL; + nssArenaMark *mark = (nssArenaMark *)NULL; + PRStatus status; + +#ifdef NSSDEBUG + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } + + if( PR_SUCCESS != nssItem_verifyPointer(ber) ) { + return (NSSPKIXAttribute *)NULL; + } +#endif /* NSSDEBUG */ + + if( (NSSArena *)NULL != arenaOpt ) { + mark = nssArena_Mark(arenaOpt); + if( (nssArenaMark *)NULL == mark ) { + goto loser; + } + } + + rv = nss_ZNEW(arenaOpt, NSSPKIXX520Name); + if( (NSSPKIXX520Name *)NULL == rv ) { + goto loser; + } + + status = nssASN1_DecodeBER(arenaOpt, rv, nssPKIXX520_template, ber); + if( PR_SUCCESS != status ) { + goto loser; + } + + if( (NSSArena *)NULL != arenaOpt ) { + rv->inArena = PR_TRUE; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arenaOpt, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_X520Name_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != nssArena_registerDestructor(arena, + nss_pkix_X520Name_remove_pointer, rv) ) { + (void)nss_pkix_X520Name_remove_pointer(rv); + goto loser; + } +#endif /* DEBUG */ + + return rv; + + loser: + if( (nssArenaMark *)NULL != mark ) { + (void)nssArena_Release(arenaOpt, mark); + } + + if( (NSSArena *)NULL == arenaOpt ) { + if( (NSSPKIXX520Name *)NULL != rv ) { + nss_ZFreeIf(rv->string.data); + nss_ZFreeIf(rv->utf8); + nss_ZFreeIf(rv); + } + } + + return (NSSPKIXX520Name *)NULL; +} diff --git a/security/nss/lib/pkix/src/X520Name/PDestroy.c b/security/nss/lib/pkix/src/X520Name/PDestroy.c new file mode 100644 index 000000000..9a9bdaaa2 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/PDestroy.c @@ -0,0 +1,87 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXX520Name_Destroy + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_X520_NAME + * + * Return value: + * PR_SUCCESS upon success + * PR_FAILURE upon failure + */ + +NSS_EXTERN NSSDER * +nssPKIXX520Name_Destroy +( + NSSPKIXX520Name *name +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name) ) { + return PR_FAILURE; + } +#endif /* NSSDEBUG */ + + if( PR_TRUE != name->inArena ) { + /* + * Note that inArena is merely a hint. If this object was + * created passively, this flag will be NULL no matter if + * it was in an arena or not. However, you may safely + * (try to) free memory in an NSSArena, so this isn't a + * problem. + */ + + if( (NSSDER *)NULL != name->der ) { + nss_ZFreeIf(name->der->data); + nss_ZFreeIf(name->der); + } + + nss_ZFreeIf(name->utf8); + nss_ZFreeIf(name->string.data); + nss_ZFreeIf(name); + } + + return PR_SUCCESS; +} diff --git a/security/nss/lib/pkix/src/X520Name/PDuplicate.c b/security/nss/lib/pkix/src/X520Name/PDuplicate.c new file mode 100644 index 000000000..a2b6d7e53 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/PDuplicate.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 PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXX520Name_Duplicate + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_X520_NAME + * NSS_ERROR_NO_MEMORY + * NSS_ERROR_INVALID_ARENA + * + * Return value: + * A valid pointer to an NSSPKIXX520Name upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSPKIXX520Name * +nssPKIXX520Name_Duplicate +( + NSSPKIXX520Name *name, + NSSArena *arenaOpt +) +{ + NSSPKIXX520Name *rv = (NSSPKIXX520Name *)NULL; + nssArenaMark *mark = (nssArenaMark *)NULL; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name) ) { + return (NSSPKIXAttribute *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSPKIXAttribute *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( (NSSArena *)NULL != arenaOpt ) { + mark = nssArena_Mark(arenaOpt); + if( (nssArenaMark *)NULL == mark ) { + goto loser; + } + } + + rv = nss_ZNEW(arenaOpt, NSSPKIXX520Name); + if( (NSSPKIXX520Name *)NULL == rv ) { + goto loser; + } + + rv->string.size = name->string.size; + rv->string.data = nss_ZAlloc(arenaOpt, name->string.size); + if( (void *)NULL == rv->string.data ) { + goto loser; + } + + (void)nsslibc_memcpy(rv->string.data, name->string.data, name->string.size); + + if( (NSSUTF8 *)NULL != name->utf8 ) { + rv->utf8 = nssUTF8_Duplicate(name->utf8, arenaOpt); + if( (NSSUTF8 *)NULL == rv->utf8 ) { + goto loser; + } + } + + if( (NSSDER *)NULL != name->der ) { + rv->der = nssItem_Duplicate(name->der, arenaOpt, (NSSItem *)NULL); + if( (NSSDER *)NULL == rv->der ) { + goto loser; + } + } + + rv->wasPrintable = name->wasPrintable; + + if( (NSSArena *)NULL != arenaOpt ) { + rv->inArena = PR_TRUE; + } + + if( (nssArenaMark *)NULL != mark ) { + if( PR_SUCCESS != nssArena_Unmark(arenaOpt, mark) ) { + goto loser; + } + } + +#ifdef DEBUG + if( PR_SUCCESS != nss_pkix_X520Name_add_pointer(rv) ) { + goto loser; + } + + if( PR_SUCCESS != nssArena_registerDestructor(arena, + nss_pkix_X520Name_remove_pointer, rv) ) { + (void)nss_pkix_X520Name_remove_pointer(rv); + goto loser; + } +#endif /* DEBUG */ + + return rv; + + loser: + if( (nssArenaMark *)NULL != mark ) { + (void)nssArena_Release(arenaOpt, mark); + } + + if( (NSSArena *)NULL == arenaOpt ) { + if( (NSSPKIXX520Name *)NULL != rv ) { + if( (NSSDER *)NULL != rv->der ) { + nss_ZFreeIf(rv->der->data); + nss_ZFreeIf(rv->der); + } + + nss_ZFreeIf(rv->string.data); + nss_ZFreeIf(rv->utf8); + nss_ZFreeIf(rv); + } + } + + return (NSSPKIXX520Name *)NULL; +} diff --git a/security/nss/lib/pkix/src/X520Name/PEncode.c b/security/nss/lib/pkix/src/X520Name/PEncode.c new file mode 100644 index 000000000..d9f001bae --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/PEncode.c @@ -0,0 +1,93 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXX520Name_Encode + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_X520_NAME + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSBER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSBER * +nssPKIXX520Name_Encode +( + NSSPKIXX520Name *name, + NSSASN1EncodingType encoding, + NSSBER *rvOpt, + NSSArena *arenaOpt +) +{ + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name) ) { + return (NSSBER *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSBER *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( (NSSDER *)NULL == name->der ) { + /* XXX fgmr */ + if( (NSSUTF8 *)NULL == name->utf8 ) { + if( PR_SUCCESS != nss_pkix_X520Name_DoUTF8(name) ) { + return (NSSBER *)NULL; + } + } + + rv->der = nssUTF8_GetDEREncoding(arenaOpt, type, rv->utf8); + if( (NSSDER *)NULL == rv->der ) { + return (NSSBER *)NULL; + } + } + + return nssItem_Duplicate(name->der, arenaOpt, rvOpt); +} diff --git a/security/nss/lib/pkix/src/X520Name/PEqual.c b/security/nss/lib/pkix/src/X520Name/PEqual.c new file mode 100644 index 000000000..9ebe75005 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/PEqual.c @@ -0,0 +1,100 @@ +/* + * 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 */ + +/* + * nssPKIXX520Name_Equal + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_X520_NAME + * + * Return value: + * PR_TRUE if the two objects have equal values + * PR_FALSE otherwise + * PR_FALSE upon error + */ + +NSS_IMPLEMENT PRBool +nssPKIXX520Name_Equal +( + NSSPKIXX520Name *name1, + NSSPKIXX520Name *name2, + PRStatus *statusOpt +) +{ + PRBool rv; + +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name1) ) { + goto loser; + } + + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name2) ) { + goto loser; + } +#endif /* NSSDEBUG */ + + if( (NSSUTF8 *)NULL == name1->utf8 ) { + if( PR_SUCCESS != nss_pkix_X520Name_DoUTF8(name1) ) { + goto loser; + } + } + + if( (NSSUTF8 *)NULL == name2->utf8 ) { + if( PR_SUCCESS != nss_pkix_X520Name_DoUTF8(name2) ) { + goto loser; + } + } + + if( (PR_TRUE == name1->wasPrintable) && (PR_TRUE == name2->wasPrintable) ) { + return nssUTF8_PrintableMatch(name1->utf8, name2->utf8, statusOpt); + } + + return nssUTF8_Equal(name1->utf8, name2->utf8, statusOpt); + + loser: + if( (PRStatus *)NULL != statusOpt ) { + *statusOpt = PR_FAILURE; + } + + return PR_FALSE; +} diff --git a/security/nss/lib/pkix/src/X520Name/PGetUTF8Encoding.c b/security/nss/lib/pkix/src/X520Name/PGetUTF8Encoding.c new file mode 100644 index 000000000..b023b1fea --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/PGetUTF8Encoding.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 PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +/* + * nssPKIXX520Name_GetUTF8Encoding + * + * + * + * The error may be one of the following values: + * NSS_ERROR_INVALID_X520_NAME + * NSS_ERROR_NO_MEMORY + * + * Return value: + * A valid NSSDER pointer upon success + * NULL upon failure + */ + +NSS_IMPLEMENT NSSUTF8 * +nssPKIXX520Name_GetUTF8Encoding +( + NSSPKIXX520Name *name, + NSSArena *arenaOpt +) +{ +#ifdef NSSDEBUG + if( PR_SUCCESS != nssPKIXX520Name_verifyPointer(name) ) { + return (NSSUTF8 *)NULL; + } + + if( (NSSArena *)NULL != arenaOpt ) { + if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) { + return (NSSUTF8 *)NULL; + } + } +#endif /* NSSDEBUG */ + + if( (NSSUTF8 *)NULL == name->utf8 ) { + if( PR_SUCCESS != nss_pkix_X520Name_DoUTF8(name) ) { + return (NSSUTF8 *)NULL; + } + } + + return nssUTF8_Duplicate(rv->utf8, arenaOpt); +} diff --git a/security/nss/lib/pkix/src/X520Name/template.c b/security/nss/lib/pkix/src/X520Name/template.c new file mode 100644 index 000000000..63f18e724 --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/template.c @@ -0,0 +1,56 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1994-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#ifdef DEBUG +static const char CVS_ID[] = "@(#) $Source$ $Revision$ $Date$ $Name$"; +#endif /* DEBUG */ + +#ifndef PKIX_H +#include "pkix.h" +#endif /* PKIX_H */ + +#ifndef ASN1_H +#include "asn1.h" +#endif /* ASN1_H */ + +/* + * nssPKIXX520Name_template + * + * + */ + +const nssASN1Template nssPKIXX520Name_template[] = { + { nssASN1_ANY, offsetof(NSSPKIXX520Name, string), NULL, + sizeof(NSSPKIXX520Name) }, + { 0 } +}; diff --git a/security/nss/lib/pkix/src/X520Name/verifyPointer.c b/security/nss/lib/pkix/src/X520Name/verifyPointer.c new file mode 100644 index 000000000..9e447797d --- /dev/null +++ b/security/nss/lib/pkix/src/X520Name/verifyPointer.c @@ -0,0 +1,169 @@ +/* + * 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_x520_name_pointer_tracker; + +/* + * nss_pkix_X520Name_add_pointer + * + * This method is only present in debug builds. + * + * This module-private routine adds an NSSPKIXX520Name 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_X520Name_add_pointer +( + const NSSPKIXX520Name *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_x520_name_pointer_tracker); + if( PR_SUCCESS != rv ) { + return rv; + } + + rv = nssPointerTracker_add(&pkix_x520_name_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + NSSError e = NSS_GetError(); + if( NSS_ERROR_NO_MEMORY != e ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + } + + return rv; + } + + return PR_SUCCESS; +} + +/* + * nss_pkix_X520Name_remove_pointer + * + * This method is only present in debug builds. + * + * This module-private routine removes a valid NSSPKIXX520Name + * 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_X520Name_remove_pointer +( + const NSSPKIXX520Name *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_remove(&pkix_x520_name_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INTERNAL_ERROR); + } + + return rv; +} + +/* + * nssPKIXX520Name_verifyPointer + * + * This method is only present in debug builds. + * + * If the specified pointer is a valid pointer to an NSSPKIXX520Name + * 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_X520_NAME + * + * Return value: + * PR_SUCCESS if the pointer is valid + * PR_FAILURE if it isn't + */ + +NSS_IMPLEMENT PRStatus +nssPKIXX520Name_verifyPointer +( + NSSPKIXX520Name *p +) +{ + PRStatus rv; + + rv = nssPointerTracker_initialize(&pkix_x520_name_pointer_tracker); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_X520_NAME); + return PR_FAILURE; + } + + rv = nssPointerTracker_verify(&pkix_x520_name_pointer_tracker, p); + if( PR_SUCCESS != rv ) { + nss_SetError(NSS_ERROR_INVALID_PKIX_X520_NAME); + return PR_FAILURE; + } + + return PR_SUCCESS; +} + +#endif /* DEBUG */ |