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