]>
Commit | Line | Data |
---|---|---|
b1ab9ed8 | 1 | /* |
d8f41ccd | 2 | * Copyright (c) 2006,2011,2014 Apple Inc. All Rights Reserved. |
b1ab9ed8 A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
24 | /* | |
25 | * opensshCoding.h - Encoding and decoding of OpenSSH format public keys. | |
26 | * | |
b1ab9ed8 A |
27 | */ |
28 | ||
29 | #ifndef _OPENSSH_CODING_H_ | |
30 | #define _OPENSSH_CODING_H_ | |
31 | ||
6b200bc3 A |
32 | #include <openssl/rsa_legacy.h> |
33 | #include <openssl/dsa_legacy.h> | |
b1ab9ed8 A |
34 | #include <Security/cssmtype.h> |
35 | #include <security_cdsa_utilities/cssmdata.h> | |
36 | #include <CoreFoundation/CFData.h> | |
37 | ||
38 | #ifdef __cplusplus | |
39 | extern "C" { | |
40 | #endif | |
41 | ||
42 | void appendUint32( | |
43 | CFMutableDataRef cfOut, | |
44 | uint32_t ui); | |
45 | uint32_t readUint32( | |
46 | const unsigned char *&cp, // IN/OUT | |
47 | unsigned &len); // IN/OUT | |
48 | ||
49 | extern CSSM_RETURN RSAPublicKeyEncodeOpenSSH1( | |
50 | RSA *openKey, | |
51 | const CssmData &descData, | |
52 | CssmOwnedData &encodedKey); | |
53 | ||
54 | extern CSSM_RETURN RSAPublicKeyDecodeOpenSSH1( | |
55 | RSA *openKey, | |
56 | void *p, | |
57 | size_t length); | |
58 | ||
59 | extern CSSM_RETURN RSAPrivateKeyEncodeOpenSSH1( | |
60 | RSA *openKey, | |
61 | const CssmData &descData, | |
62 | CssmOwnedData &encodedKey); | |
63 | ||
64 | extern CSSM_RETURN RSAPrivateKeyDecodeOpenSSH1( | |
65 | RSA *openKey, | |
66 | void *p, | |
67 | size_t length); | |
68 | ||
69 | extern CSSM_RETURN RSAPublicKeyEncodeOpenSSH2( | |
70 | RSA *openKey, | |
71 | const CssmData &descData, | |
72 | CssmOwnedData &encodedKey); | |
73 | ||
74 | extern CSSM_RETURN RSAPublicKeyDecodeOpenSSH2( | |
75 | RSA *openKey, | |
76 | void *p, | |
77 | size_t length); | |
78 | ||
79 | extern CSSM_RETURN DSAPublicKeyEncodeOpenSSH2( | |
80 | DSA *openKey, | |
81 | const CssmData &descData, | |
82 | CssmOwnedData &encodedKey); | |
83 | ||
84 | extern CSSM_RETURN DSAPublicKeyDecodeOpenSSH2( | |
85 | DSA *openKey, | |
86 | void *p, | |
87 | size_t length); | |
88 | ||
89 | /* In opensshWrap.cpp */ | |
90 | ||
91 | /* Encode OpenSSHv1 private key, with or without encryption */ | |
92 | extern CSSM_RETURN encodeOpenSSHv1PrivKey( | |
93 | RSA *r, | |
94 | const uint8 *comment, /* optional */ | |
95 | unsigned commentLen, | |
96 | const uint8 *encryptKey, /* optional; if present, it's 16 bytes of MD5(password) */ | |
97 | CFDataRef *encodedKey); /* RETURNED */ | |
98 | ||
99 | extern CSSM_RETURN decodeOpenSSHv1PrivKey( | |
100 | const unsigned char *encodedKey, | |
101 | unsigned encodedKeyLen, | |
102 | RSA *r, | |
103 | const uint8 *decryptKey, /* optional; if present, it's 16 bytes of MD5(password) */ | |
104 | uint8 **comment, /* mallocd and RETURNED */ | |
105 | unsigned *commentLen); /* RETURNED */ | |
106 | ||
107 | #ifdef __cplusplus | |
108 | } | |
109 | #endif | |
110 | ||
111 | #endif /* _OPENSSH_CODING_H_ */ |