]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/p12/pkcs12Parsed.cpp
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / clxutils / p12 / pkcs12Parsed.cpp
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved.
3 *
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please
7 * obtain a copy of the License at http://www.apple.com/publicsource and
8 * read it before using this file.
9 *
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
12 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
13 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
15 * Please see the License for the specific language governing rights and
16 * limitations under the License.
17 */
18
19 /*
20 * pkcs12Parsed.h - Parsed contents of a p12 blob
21 */
22
23 #include "pkcs12Parsed.h"
24 #include <string.h>
25
26 P12KnownBlobs::P12KnownBlobs(
27 SecNssCoder &coder)
28 : mBlobs(NULL), mNumBlobs(0), mCoder(coder)
29 {
30
31 }
32
33 void P12KnownBlobs::addBlob(
34 const CSSM_DATA &blob)
35 {
36 /* coder doesn't have a realloc */
37 CSSM_DATA *newBlobs =
38 (CSSM_DATA *)mCoder.malloc((mNumBlobs + 1) * sizeof(CSSM_DATA));
39 memmove(newBlobs, mBlobs, mNumBlobs * sizeof(CSSM_DATA));
40 newBlobs[mNumBlobs++] = blob;
41 mBlobs = newBlobs;
42 }
43
44 P12UnknownBlob::P12UnknownBlob(
45 const CSSM_DATA &blob,
46 const char *descr)
47 {
48 mBlob = blob;
49 mOid.Data = NULL;
50 mOid.Length = 0;
51 strcpy(mDescr, descr);
52 }
53
54 P12UnknownBlob::P12UnknownBlob(
55 const CSSM_DATA &blob,
56 const CSSM_OID &oid)
57 {
58 mBlob = blob;
59 mOid = oid;
60 mDescr[0] = '\0';
61 }
62
63 P12UnknownBlobs::P12UnknownBlobs(
64 SecNssCoder &coder)
65 : mBlobs(NULL), mNumBlobs(0), mCoder(coder)
66 {
67
68 }
69
70 P12UnknownBlobs::~P12UnknownBlobs()
71 {
72 for(unsigned dex=0; dex<mNumBlobs; dex++) {
73 delete mBlobs[dex];
74 }
75 }
76
77 void P12UnknownBlobs::addBlob(
78 P12UnknownBlob *blob)
79 {
80 /* coder doesn't have a realloc */
81 P12UnknownBlob **newBlobs =
82 (P12UnknownBlob **)mCoder.malloc((mNumBlobs + 1) *
83 sizeof(P12UnknownBlob *));
84 memmove(newBlobs, mBlobs, mNumBlobs * sizeof(P12UnknownBlob *));
85 newBlobs[mNumBlobs++] = blob;
86 mBlobs = newBlobs;
87 }
88
89 P12Parsed::P12Parsed(SecNssCoder &coder)
90 : mCoder(coder), mCerts(coder), mCrls(coder), mUnknown(coder)
91 {
92
93 }