1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/pki/certdecode.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef PKIT_H 1.9 +#include "pkit.h" 1.10 +#endif /* PKIT_H */ 1.11 + 1.12 +#ifndef PKIM_H 1.13 +#include "pkim.h" 1.14 +#endif /* PKIM_H */ 1.15 + 1.16 +/* This is defined in pki3hack.c */ 1.17 +NSS_EXTERN nssDecodedCert * 1.18 +nssDecodedPKIXCertificate_Create ( 1.19 + NSSArena *arenaOpt, 1.20 + NSSDER *encoding 1.21 +); 1.22 + 1.23 +NSS_IMPLEMENT PRStatus 1.24 +nssDecodedPKIXCertificate_Destroy ( 1.25 + nssDecodedCert *dc 1.26 +); 1.27 + 1.28 +NSS_IMPLEMENT nssDecodedCert * 1.29 +nssDecodedCert_Create ( 1.30 + NSSArena *arenaOpt, 1.31 + NSSDER *encoding, 1.32 + NSSCertificateType type 1.33 +) 1.34 +{ 1.35 + nssDecodedCert *rvDC = NULL; 1.36 + switch(type) { 1.37 + case NSSCertificateType_PKIX: 1.38 + rvDC = nssDecodedPKIXCertificate_Create(arenaOpt, encoding); 1.39 + break; 1.40 + default: 1.41 +#if 0 1.42 + nss_SetError(NSS_ERROR_INVALID_ARGUMENT); 1.43 +#endif 1.44 + return (nssDecodedCert *)NULL; 1.45 + } 1.46 + return rvDC; 1.47 +} 1.48 + 1.49 +NSS_IMPLEMENT PRStatus 1.50 +nssDecodedCert_Destroy ( 1.51 + nssDecodedCert *dc 1.52 +) 1.53 +{ 1.54 + if (!dc) { 1.55 + return PR_FAILURE; 1.56 + } 1.57 + switch(dc->type) { 1.58 + case NSSCertificateType_PKIX: 1.59 + return nssDecodedPKIXCertificate_Destroy(dc); 1.60 + default: 1.61 +#if 0 1.62 + nss_SetError(NSS_ERROR_INVALID_ARGUMENT); 1.63 +#endif 1.64 + break; 1.65 + } 1.66 + return PR_FAILURE; 1.67 +} 1.68 +