diff options
author | cvs2hg <devnull@localhost> | 2013-02-21 22:12:45 +0100 |
---|---|---|
committer | cvs2hg <devnull@localhost> | 2013-02-21 22:12:45 +0100 |
commit | ba0cbe2c7d3c2b7640fb84c36f02aab0459c4e0b (patch) | |
tree | 916501d96e0b3a1edc1aa75f66ecf79c6abf814c /security/nss/lib/pkix/src/AttributeTypeAndValue | |
parent | 52117abf63f8c4dbeb439c0dec376989845de7c6 (diff) | |
parent | db9894ead5167463ea02f460e3b4e66221d6d60e (diff) | |
download | nss-hg-ba0cbe2c7d3c2b7640fb84c36f02aab0459c4e0b.tar.gz |
artificial changeset: close fixup head 3836ae9d564a for tag Makefile
Diffstat (limited to 'security/nss/lib/pkix/src/AttributeTypeAndValue')
27 files changed, 2543 insertions, 0 deletions
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 */ + |