X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/b04fe171f0375ecd5d8a24747ca1dff85720a0ca..6b200bc335dc93c5516ccb52f14bd896d8c7fad7:/SecurityTests/clxutils/p12Parse/pkcs12Utils.cpp diff --git a/SecurityTests/clxutils/p12Parse/pkcs12Utils.cpp b/SecurityTests/clxutils/p12Parse/pkcs12Utils.cpp deleted file mode 100644 index c496bed4..00000000 --- a/SecurityTests/clxutils/p12Parse/pkcs12Utils.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 2003,2005 Apple Computer, Inc. All Rights Reserved. - * - * The contents of this file constitute Original Code as defined in and are - * subject to the Apple Public Source License Version 1.2 (the 'License'). - * You may not use this file except in compliance with the License. Please - * obtain a copy of the License at http://www.apple.com/publicsource and - * read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - */ - -/* - * pkcs12Utils.cpp - standalone copies of utility functions from libsecurity_pkcs12 - */ - -#include "pkcs12Utils.h" -#include -#include -#include - -/* CSSM_DATA --> uint32. Returns true if OK. */ -bool p12DataToInt( - const CSSM_DATA &cdata, - uint32 &u) -{ - if((cdata.Length == 0) || (cdata.Data == NULL)) { - /* default/not present */ - u = 0; - return true; - } - uint32 len = cdata.Length; - if(len > sizeof(uint32)) { - return false; - } - - uint32 rtn = 0; - uint8 *cp = cdata.Data; - for(uint32 i=0; ioid)) { - keyAlg = info->keyAlg; - encrAlg = info->encrAlg; - pbeHashAlg = info->pbeHashAlg; - keySizeInBits = info->keySizeInBits; - blockSizeInBytes = info->blockSizeInBytes; - padding = info->padding; - mode = info->mode; - pkcs = info->pkcs; - return true; - } - info++; - } - return false; -} - -/* - * Enum to string mappper. - * Maybe DEBUG only. - */ -/* - * Each type of attribute has a name/value pair in a table of these: - */ -typedef struct { - unsigned value; - const char *name; -} p12NameValuePair; - -/* declare one entry in a table of p12NameValuePair */ -#define NVP(attr) {attr, #attr} - -/* the NULL entry which terminates all p12NameValuePair tables */ -#define NVP_END {0, NULL} - -static const p12NameValuePair p7CITypeNames[] = -{ - NVP(CT_None), - NVP(CT_Data), - NVP(CT_SignedData), - NVP(CT_EnvData), - NVP(CT_SignedEnvData), - NVP(CT_DigestData), - NVP(CT_EncryptedData), - NVP_END -}; - -static const p12NameValuePair p12BagTypeNames[] = -{ - NVP(BT_None), - NVP(BT_KeyBag), - NVP(BT_ShroudedKeyBag), - NVP(BT_CertBag), - NVP(BT_CrlBag), - NVP(BT_SecretBag), - NVP(BT_SafeContentsBag), - NVP_END -}; - -static const char *typeToStr( - unsigned type, - const p12NameValuePair *table) -{ - while(table->name) { - if(table->value == type) { - return table->name; - } - table++; - } - return "Unknown"; -} - -const char *p12BagTypeStr( - NSS_P12_SB_Type type) -{ - return typeToStr(type, p12BagTypeNames); -} - -const char *p7ContentInfoTypeStr( - NSS_P7_CI_Type type) -{ - return typeToStr(type, p7CITypeNames); -}