]> git.saurik.com Git - apple/security.git/blob - OSX/include/security_cryptkit/CryptKitAsn1.cpp
Security-57336.1.9.tar.gz
[apple/security.git] / OSX / include / security_cryptkit / CryptKitAsn1.cpp
1 /*
2 * CryptKitAsn1.cpp - ASN1 templates for FEE keys and signatures
3 */
4
5 #include "CryptKitAsn1.h"
6 #include <security_asn1/secasn1.h>
7
8 /*
9 * Unlike RSA, DSA, and Diffie-Hellman, the integers in these
10 * objects are indeed signed.
11 */
12 #define SEC_ASN1_SIGNED (SEC_ASN1_SIGNED_INT | SEC_ASN1_INTEGER)
13
14 /* FEECurveParametersASN1 */
15 const SecAsn1Template FEECurveParametersASN1Template[] = {
16 { SEC_ASN1_SEQUENCE,
17 0, NULL, sizeof(FEECurveParametersASN1) },
18 { SEC_ASN1_INTEGER, offsetof(FEECurveParametersASN1,primeType) },
19 { SEC_ASN1_INTEGER, offsetof(FEECurveParametersASN1,curveType) },
20 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,q) },
21 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,k) },
22 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,m) },
23 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,a) },
24 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,b_) },
25 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,c) },
26 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,x1Plus) },
27 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,x1Minus) },
28 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,cOrderPlus) },
29 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,cOrderMinus) },
30 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,x1OrderPlus) },
31 { SEC_ASN1_SIGNED, offsetof(FEECurveParametersASN1,x1OrderMinus) },
32 { SEC_ASN1_SIGNED | SEC_ASN1_OPTIONAL,
33 offsetof(FEECurveParametersASN1,basePrime) },
34 { 0, }
35 };
36
37 /* FEEElGamalSignatureASN1 */
38 const SecAsn1Template FEEElGamalSignatureASN1Template[] = {
39 { SEC_ASN1_SEQUENCE,
40 0, NULL, sizeof(FEEElGamalSignatureASN1) },
41 { SEC_ASN1_SIGNED, offsetof(FEEElGamalSignatureASN1,u) },
42 { SEC_ASN1_SIGNED, offsetof(FEEElGamalSignatureASN1,pmX) },
43 { 0, }
44 };
45
46 /* FEEECDSASignatureASN1 */
47 const SecAsn1Template FEEECDSASignatureASN1Template[] = {
48 { SEC_ASN1_SEQUENCE,
49 0, NULL, sizeof(FEEECDSASignatureASN1) },
50 { SEC_ASN1_SIGNED, offsetof(FEEECDSASignatureASN1,c) },
51 { SEC_ASN1_SIGNED, offsetof(FEEECDSASignatureASN1,d) },
52 { 0, }
53 };
54
55 /* FEEPublicKeyASN1 */
56 const SecAsn1Template FEEPublicKeyASN1Template[] = {
57 { SEC_ASN1_SEQUENCE,
58 0, NULL, sizeof(FEEPublicKeyASN1) },
59 { SEC_ASN1_SIGNED, offsetof(FEEPublicKeyASN1,version) },
60 { SEC_ASN1_INLINE,
61 offsetof(FEEPublicKeyASN1,curveParams),
62 FEECurveParametersASN1Template },
63 { SEC_ASN1_SIGNED, offsetof(FEEPublicKeyASN1,plusX) },
64 { SEC_ASN1_SIGNED, offsetof(FEEPublicKeyASN1,minusX) },
65 { SEC_ASN1_SIGNED | SEC_ASN1_OPTIONAL,
66 offsetof(FEEPublicKeyASN1,plusY) },
67 { 0, }
68 };
69
70 /* FEEPrivateKeyASN1 */
71 const SecAsn1Template FEEPrivateKeyASN1Template[] = {
72 { SEC_ASN1_SEQUENCE,
73 0, NULL, sizeof(FEEPrivateKeyASN1) },
74 { SEC_ASN1_SIGNED, offsetof(FEEPrivateKeyASN1,version) },
75 { SEC_ASN1_INLINE,
76 offsetof(FEEPrivateKeyASN1,curveParams),
77 FEECurveParametersASN1Template },
78 { SEC_ASN1_SIGNED, offsetof(FEEPrivateKeyASN1,privData) },
79 { 0, }
80 };
81
82