]> git.saurik.com Git - apple/security.git/blob - AppleCSP/open_ssl/opensslUtils/openRsaSnacc.h
Security-54.1.tar.gz
[apple/security.git] / AppleCSP / open_ssl / opensslUtils / openRsaSnacc.h
1 /*
2 * Copyright (c) 2000-2001 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 obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
8 * 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 EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
16 */
17
18
19 /*
20 * openRsaSnacc.h - glue between openrsa and SNACC
21 */
22
23 #ifndef _OPEN_RSA_SNACC_H_
24 #define _OPEN_RSA_SNACC_H_
25
26
27 #include <openssl/rsa.h>
28 #include <openssl/dsa.h>
29 #include <openssl/dh.h>
30 #include <Security/cssmtype.h>
31 #include <Security/cssmdata.h>
32 #include <Security/asn-incl.h>
33 #include <Security/sm_vdatypes.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /*
40 * Convert between SNACC-style BigIntegerStr and openssl-style BIGNUM.
41 */
42 BIGNUM *bigIntStrToBn(
43 BigIntegerStr &snaccInt);
44 void bnToBigIntStr(
45 BIGNUM *bn,
46 BigIntegerStr &snaccInt);
47
48
49 /* estimate size of encoded BigIntegerStr */
50 unsigned sizeofBigInt(
51 BigIntegerStr &bigInt);
52
53 /*
54 * int --> BigIntegerStr
55 */
56 void snaccIntToBigIntegerStr(
57 int i,
58 BigIntegerStr &bigInt);
59
60 /*
61 * Replacements for d2i_RSAPublicKey, etc.
62 */
63 CSSM_RETURN RSAPublicKeyDecode(
64 RSA *openKey,
65 void *p,
66 size_t length);
67 CSSM_RETURN RSAPublicKeyEncode(
68 RSA *openKey,
69 CssmOwnedData &encodedKey);
70 CSSM_RETURN RSAPrivateKeyDecode(
71 RSA *openKey,
72 void *p,
73 size_t length);
74 CSSM_RETURN RSAPrivateKeyEncode(
75 RSA *openKey,
76 CssmOwnedData &encodedKey);
77
78 CSSM_RETURN generateDigestInfo(
79 const void *messageDigest,
80 size_t digestLen,
81 CSSM_ALGORITHMS digestAlg, // CSSM_ALGID_SHA1, etc.
82 CssmOwnedData &encodedInfo,
83 size_t maxEncodedSize);
84
85 CSSM_RETURN DSAPublicKeyDecode(
86 DSA *openKey,
87 unsigned char *p,
88 unsigned length);
89 CSSM_RETURN DSAPublicKeyEncode(
90 DSA *openKey,
91 CssmOwnedData &encodedKey);
92 CSSM_RETURN DSAPrivateKeyDecode(
93 DSA *openKey,
94 unsigned char *p,
95 unsigned length);
96 CSSM_RETURN DSAPrivateKeyEncode(
97 DSA *openKey,
98 CssmOwnedData &encodedKey);
99
100 CSSM_RETURN DSASigEncode(
101 DSA_SIG *openSig,
102 CssmOwnedData &encodedSig);
103 CSSM_RETURN DSASigDecode(
104 DSA_SIG *openSig,
105 const void *p,
106 unsigned length);
107
108 CSSM_RETURN DHPrivateKeyDecode(
109 DH *openKey,
110 unsigned char *p,
111 unsigned length);
112 CSSM_RETURN DHPrivateKeyEncode(
113 DH *openKey,
114 CssmOwnedData &encodedKey);
115
116
117 #ifdef __cplusplus
118 }
119 #endif
120
121 #endif /* _OPEN_RSA_SNACC_H_ */