]> git.saurik.com Git - apple/security.git/blob - AppleCSP/open_ssl/opensslUtils/openRsaSnacc.h
Security-29.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 <Security/cssmtype.h>
30 #include <Security/cssmdata.h>
31 #include <Security/asn-incl.h>
32 #include <Security/sm_vdatypes.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 /*
39 * Convert between SNACC-style BigIntegerStr and openssl-style BIGNUM.
40 */
41 BIGNUM *bigIntStrToBn(
42 BigIntegerStr &snaccInt);
43 void bnToBigIntStr(
44 BIGNUM *bn,
45 BigIntegerStr &snaccInt);
46
47
48 /* estimate size of encoded BigIntegerStr */
49 unsigned sizeofBigInt(
50 BigIntegerStr &bigInt);
51
52 /*
53 * Replacements for d2i_RSAPublicKey, etc.
54 */
55 CSSM_RETURN RSAPublicKeyDecode(
56 RSA *openKey,
57 void *p,
58 size_t length);
59 CSSM_RETURN RSAPublicKeyEncode(
60 RSA *openKey,
61 CssmOwnedData &encodedKey);
62 CSSM_RETURN RSAPrivateKeyDecode(
63 RSA *openKey,
64 void *p,
65 size_t length);
66 CSSM_RETURN RSAPrivateKeyEncode(
67 RSA *openKey,
68 CssmOwnedData &encodedKey);
69
70 CSSM_RETURN generateDigestInfo(
71 const void *messageDigest,
72 size_t digestLen,
73 CSSM_ALGORITHMS digestAlg, // CSSM_ALGID_SHA1, etc.
74 CssmOwnedData &encodedInfo,
75 size_t maxEncodedSize);
76
77 CSSM_RETURN DSAPublicKeyDecode(
78 DSA *openKey,
79 unsigned char *p,
80 unsigned length);
81 CSSM_RETURN DSAPublicKeyEncode(
82 DSA *openKey,
83 CssmOwnedData &encodedKey);
84 CSSM_RETURN DSAPrivateKeyDecode(
85 DSA *openKey,
86 unsigned char *p,
87 unsigned length);
88 CSSM_RETURN DSAPrivateKeyEncode(
89 DSA *openKey,
90 CssmOwnedData &encodedKey);
91
92 CSSM_RETURN DSASigEncode(
93 DSA_SIG *openSig,
94 CssmOwnedData &encodedSig);
95 CSSM_RETURN DSASigDecode(
96 DSA_SIG *openSig,
97 const void *p,
98 unsigned length);
99
100
101 #ifdef __cplusplus
102 }
103 #endif
104
105 #endif /* _OPEN_RSA_SNACC_H_ */