OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_BASE_ASN1_UTIL_H_ | 5 #ifndef NET_BASE_ASN1_UTIL_H_ |
6 #define NET_BASE_ASN1_UTIL_H_ | 6 #define NET_BASE_ASN1_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
| 10 #include "net/base/net_api.h" |
10 | 11 |
11 namespace net { | 12 namespace net { |
12 | 13 |
13 namespace asn1 { | 14 namespace asn1 { |
14 | 15 |
15 // These are the DER encodings of the tag byte for ASN.1 objects. | 16 // These are the DER encodings of the tag byte for ASN.1 objects. |
16 static const unsigned kINTEGER = 0x02; | 17 static const unsigned kINTEGER = 0x02; |
17 static const unsigned kOID = 0x06; | 18 static const unsigned kOID = 0x06; |
18 static const unsigned kSEQUENCE = 0x30; | 19 static const unsigned kSEQUENCE = 0x30; |
19 | 20 |
(...skipping 18 matching lines...) Expand all Loading... |
38 // GetElement performs the same actions as ParseElement, except that the header | 39 // GetElement performs the same actions as ParseElement, except that the header |
39 // bytes are not included in the output. | 40 // bytes are not included in the output. |
40 bool GetElement(base::StringPiece* in, | 41 bool GetElement(base::StringPiece* in, |
41 unsigned tag_value, | 42 unsigned tag_value, |
42 base::StringPiece* out); | 43 base::StringPiece* out); |
43 | 44 |
44 | 45 |
45 // ExtractSPKIFromDERCert parses the DER encoded certificate in |cert| and | 46 // ExtractSPKIFromDERCert parses the DER encoded certificate in |cert| and |
46 // extracts the bytes of the SubjectPublicKeyInfo. On successful return, | 47 // extracts the bytes of the SubjectPublicKeyInfo. On successful return, |
47 // |spki_out| is set to contain the SPKI, pointing into |cert|. | 48 // |spki_out| is set to contain the SPKI, pointing into |cert|. |
48 bool ExtractSPKIFromDERCert(base::StringPiece cert, | 49 NET_TEST bool ExtractSPKIFromDERCert(base::StringPiece cert, |
49 base::StringPiece* spki_out); | 50 base::StringPiece* spki_out); |
50 | 51 |
51 } // namespace asn1 | 52 } // namespace asn1 |
52 | 53 |
53 } // namespace net | 54 } // namespace net |
54 | 55 |
55 #endif // NET_BASE_ASN1_UTIL_H_ | 56 #endif // NET_BASE_ASN1_UTIL_H_ |
OLD | NEW |