diff options
author | doug <> | 2015-06-13 09:02:45 +0000 |
---|---|---|
committer | doug <> | 2015-06-13 09:02:45 +0000 |
commit | 159f76928fe13123fd28148a0ad396034f1a1f8f (patch) | |
tree | afb971489f3b99496aa4fda22116642e32ead2ed /src | |
parent | 7f7999bf62a2909a02c91df3194a58221ef505e1 (diff) | |
download | openbsd-159f76928fe13123fd28148a0ad396034f1a1f8f.tar.gz openbsd-159f76928fe13123fd28148a0ad396034f1a1f8f.tar.bz2 openbsd-159f76928fe13123fd28148a0ad396034f1a1f8f.zip |
Add comments about how the CBS constants are constructed.
Also, introduce a few more #defines to make it obvious.
ok miod@ jsing@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/bytestring.h | 55 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/bytestring.h | 55 |
2 files changed, 86 insertions, 24 deletions
diff --git a/src/lib/libssl/bytestring.h b/src/lib/libssl/bytestring.h index c2b94c31a2..b98c930da5 100644 --- a/src/lib/libssl/bytestring.h +++ b/src/lib/libssl/bytestring.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bytestring.h,v 1.5 2015/04/29 02:11:09 doug Exp $ */ | 1 | /* $OpenBSD: bytestring.h,v 1.6 2015/06/13 09:02:45 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -152,17 +152,48 @@ int CBS_get_u24_length_prefixed(CBS *cbs, CBS *out); | |||
152 | 152 | ||
153 | /* Parsing ASN.1 */ | 153 | /* Parsing ASN.1 */ |
154 | 154 | ||
155 | #define CBS_ASN1_BOOLEAN 0x1 | 155 | /* |
156 | #define CBS_ASN1_INTEGER 0x2 | 156 | * While an identifier can be multiple octets, this library only handles the |
157 | #define CBS_ASN1_BITSTRING 0x3 | 157 | * single octet variety currently. This limits support up to tag number 30 |
158 | #define CBS_ASN1_OCTETSTRING 0x4 | 158 | * since tag number 31 is a reserved value to indicate multiple octets. |
159 | #define CBS_ASN1_OBJECT 0x6 | 159 | */ |
160 | #define CBS_ASN1_ENUMERATED 0xa | 160 | |
161 | #define CBS_ASN1_SEQUENCE (0x10 | CBS_ASN1_CONSTRUCTED) | 161 | /* Bits 8 and 7: class tag type: See X.690 section 8.1.2.2. */ |
162 | #define CBS_ASN1_SET (0x11 | CBS_ASN1_CONSTRUCTED) | 162 | #define CBS_ASN1_UNIVERSAL 0x00 |
163 | 163 | #define CBS_ASN1_APPLICATION 0x40 | |
164 | #define CBS_ASN1_CONSTRUCTED 0x20 | 164 | #define CBS_ASN1_CONTEXT_SPECIFIC 0x80 |
165 | #define CBS_ASN1_CONTEXT_SPECIFIC 0x80 | 165 | #define CBS_ASN1_PRIVATE 0xc0 |
166 | |||
167 | /* Bit 6: Primitive or constructed: See X.690 section 8.1.2.3. */ | ||
168 | #define CBS_ASN1_PRIMITIVE 0x00 | ||
169 | #define CBS_ASN1_CONSTRUCTED 0x20 | ||
170 | |||
171 | /* | ||
172 | * Bits 5 to 1 are the tag number. See X.680 section 8.6 for tag numbers of | ||
173 | * the universal class. | ||
174 | */ | ||
175 | |||
176 | /* | ||
177 | * Common universal identifier octets. | ||
178 | * See X.690 section 8.1 and X.680 section 8.6 for universal tag numbers. | ||
179 | * | ||
180 | * Note: These definitions are the cause of some of the strange behavior in | ||
181 | * CBS's bs_ber.c. | ||
182 | * | ||
183 | * In BER, it is the sender's option to use primitive or constructed for | ||
184 | * bitstring (X.690 section 8.6.1) and octetstring (X.690 section 8.7.1). | ||
185 | * | ||
186 | * In DER, bitstring and octetstring are required to be primitive | ||
187 | * (X.690 section 10.2). | ||
188 | */ | ||
189 | #define CBS_ASN1_BOOLEAN (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0x1) | ||
190 | #define CBS_ASN1_INTEGER (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0x2) | ||
191 | #define CBS_ASN1_BITSTRING (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0x3) | ||
192 | #define CBS_ASN1_OCTETSTRING (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0x4) | ||
193 | #define CBS_ASN1_OBJECT (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0x6) | ||
194 | #define CBS_ASN1_ENUMERATED (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0xa) | ||
195 | #define CBS_ASN1_SEQUENCE (CBS_ASN1_UNIVERSAL | CBS_ASN1_CONSTRUCTED | 0x10) | ||
196 | #define CBS_ASN1_SET (CBS_ASN1_UNIVERSAL | CBS_ASN1_CONSTRUCTED | 0x11) | ||
166 | 197 | ||
167 | /* | 198 | /* |
168 | * CBS_get_asn1 sets |*out| to the contents of DER-encoded, ASN.1 element (not | 199 | * CBS_get_asn1 sets |*out| to the contents of DER-encoded, ASN.1 element (not |
diff --git a/src/lib/libssl/src/ssl/bytestring.h b/src/lib/libssl/src/ssl/bytestring.h index c2b94c31a2..b98c930da5 100644 --- a/src/lib/libssl/src/ssl/bytestring.h +++ b/src/lib/libssl/src/ssl/bytestring.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bytestring.h,v 1.5 2015/04/29 02:11:09 doug Exp $ */ | 1 | /* $OpenBSD: bytestring.h,v 1.6 2015/06/13 09:02:45 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -152,17 +152,48 @@ int CBS_get_u24_length_prefixed(CBS *cbs, CBS *out); | |||
152 | 152 | ||
153 | /* Parsing ASN.1 */ | 153 | /* Parsing ASN.1 */ |
154 | 154 | ||
155 | #define CBS_ASN1_BOOLEAN 0x1 | 155 | /* |
156 | #define CBS_ASN1_INTEGER 0x2 | 156 | * While an identifier can be multiple octets, this library only handles the |
157 | #define CBS_ASN1_BITSTRING 0x3 | 157 | * single octet variety currently. This limits support up to tag number 30 |
158 | #define CBS_ASN1_OCTETSTRING 0x4 | 158 | * since tag number 31 is a reserved value to indicate multiple octets. |
159 | #define CBS_ASN1_OBJECT 0x6 | 159 | */ |
160 | #define CBS_ASN1_ENUMERATED 0xa | 160 | |
161 | #define CBS_ASN1_SEQUENCE (0x10 | CBS_ASN1_CONSTRUCTED) | 161 | /* Bits 8 and 7: class tag type: See X.690 section 8.1.2.2. */ |
162 | #define CBS_ASN1_SET (0x11 | CBS_ASN1_CONSTRUCTED) | 162 | #define CBS_ASN1_UNIVERSAL 0x00 |
163 | 163 | #define CBS_ASN1_APPLICATION 0x40 | |
164 | #define CBS_ASN1_CONSTRUCTED 0x20 | 164 | #define CBS_ASN1_CONTEXT_SPECIFIC 0x80 |
165 | #define CBS_ASN1_CONTEXT_SPECIFIC 0x80 | 165 | #define CBS_ASN1_PRIVATE 0xc0 |
166 | |||
167 | /* Bit 6: Primitive or constructed: See X.690 section 8.1.2.3. */ | ||
168 | #define CBS_ASN1_PRIMITIVE 0x00 | ||
169 | #define CBS_ASN1_CONSTRUCTED 0x20 | ||
170 | |||
171 | /* | ||
172 | * Bits 5 to 1 are the tag number. See X.680 section 8.6 for tag numbers of | ||
173 | * the universal class. | ||
174 | */ | ||
175 | |||
176 | /* | ||
177 | * Common universal identifier octets. | ||
178 | * See X.690 section 8.1 and X.680 section 8.6 for universal tag numbers. | ||
179 | * | ||
180 | * Note: These definitions are the cause of some of the strange behavior in | ||
181 | * CBS's bs_ber.c. | ||
182 | * | ||
183 | * In BER, it is the sender's option to use primitive or constructed for | ||
184 | * bitstring (X.690 section 8.6.1) and octetstring (X.690 section 8.7.1). | ||
185 | * | ||
186 | * In DER, bitstring and octetstring are required to be primitive | ||
187 | * (X.690 section 10.2). | ||
188 | */ | ||
189 | #define CBS_ASN1_BOOLEAN (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0x1) | ||
190 | #define CBS_ASN1_INTEGER (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0x2) | ||
191 | #define CBS_ASN1_BITSTRING (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0x3) | ||
192 | #define CBS_ASN1_OCTETSTRING (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0x4) | ||
193 | #define CBS_ASN1_OBJECT (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0x6) | ||
194 | #define CBS_ASN1_ENUMERATED (CBS_ASN1_UNIVERSAL | CBS_ASN1_PRIMITIVE | 0xa) | ||
195 | #define CBS_ASN1_SEQUENCE (CBS_ASN1_UNIVERSAL | CBS_ASN1_CONSTRUCTED | 0x10) | ||
196 | #define CBS_ASN1_SET (CBS_ASN1_UNIVERSAL | CBS_ASN1_CONSTRUCTED | 0x11) | ||
166 | 197 | ||
167 | /* | 198 | /* |
168 | * CBS_get_asn1 sets |*out| to the contents of DER-encoded, ASN.1 element (not | 199 | * CBS_get_asn1 sets |*out| to the contents of DER-encoded, ASN.1 element (not |