Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_DER_PARSE_VALUES_H_ | 5 #ifndef NET_DER_PARSE_VALUES_H_ |
| 6 #define NET_DER_PARSE_VALUES_H_ | 6 #define NET_DER_PARSE_VALUES_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "net/base/net_export.h" | 9 #include "net/base/net_export.h" |
| 10 #include "net/der/input.h" | 10 #include "net/der/input.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 NET_EXPORT bool ParseBoolRelaxed(const Input& in, bool* out) WARN_UNUSED_RESULT; | 23 NET_EXPORT bool ParseBoolRelaxed(const Input& in, bool* out) WARN_UNUSED_RESULT; |
| 24 | 24 |
| 25 // Reads a DER-encoded ASN.1 INTEGER value from |in| and puts the resulting | 25 // Reads a DER-encoded ASN.1 INTEGER value from |in| and puts the resulting |
| 26 // value in |out|. ASN.1 INTEGERs are arbitrary precision; this function is | 26 // value in |out|. ASN.1 INTEGERs are arbitrary precision; this function is |
| 27 // provided as a convenience when the caller knows that the value is unsigned | 27 // provided as a convenience when the caller knows that the value is unsigned |
| 28 // and is between 0 and 2^63-1. This function does not support the full range of | 28 // and is between 0 and 2^63-1. This function does not support the full range of |
| 29 // uint64_t. This function returns false if the value is too big to fit in a | 29 // uint64_t. This function returns false if the value is too big to fit in a |
| 30 // uint64_t, is negative, or if there is an error reading the integer. | 30 // uint64_t, is negative, or if there is an error reading the integer. |
| 31 NET_EXPORT bool ParseUint64(const Input& in, uint64_t* out) WARN_UNUSED_RESULT; | 31 NET_EXPORT bool ParseUint64(const Input& in, uint64_t* out) WARN_UNUSED_RESULT; |
| 32 | 32 |
| 33 // Reads a DER-encoded ASN.1 BIT STRING value from |in| and puts the resulting | |
| 34 // octet string into |bytes|, and the number of unused bits into |unused_bits|. | |
| 35 // Returns true on success, otherwise returns false and does not modify the | |
| 36 // out-parameters. | |
| 37 // | |
| 38 // On success it can be assumed that: | |
| 39 // * |*unused_bits| < 8 | |
| 40 // * The final byte of |bytes| has its |*unused_bits| least significant bits | |
| 41 // set to 0. | |
| 42 NET_EXPORT bool ParseBitString(const Input& in, | |
| 43 Input* bytes, | |
| 44 uint8_t* unused_bits) WARN_UNUSED_RESULT; | |
|
nharper
2015/07/21 23:23:47
Should unused_bits be a size_t* instead? I realize
eroman
2015/07/22 17:05:23
I would argue for a uint8_t on the grounds that it
| |
| 45 | |
| 33 struct GeneralizedTime { | 46 struct GeneralizedTime { |
| 34 uint16_t year; | 47 uint16_t year; |
| 35 uint8_t month; | 48 uint8_t month; |
| 36 uint8_t day; | 49 uint8_t day; |
| 37 uint8_t hours; | 50 uint8_t hours; |
| 38 uint8_t minutes; | 51 uint8_t minutes; |
| 39 uint8_t seconds; | 52 uint8_t seconds; |
| 40 }; | 53 }; |
| 41 | 54 |
| 42 NET_EXPORT_PRIVATE bool operator<(const GeneralizedTime& lhs, | 55 NET_EXPORT_PRIVATE bool operator<(const GeneralizedTime& lhs, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 60 // DER rules - it follows the rules from RFC5280, which does not allow for | 73 // DER rules - it follows the rules from RFC5280, which does not allow for |
| 61 // fractional seconds. | 74 // fractional seconds. |
| 62 NET_EXPORT bool ParseGeneralizedTime(const Input& in, | 75 NET_EXPORT bool ParseGeneralizedTime(const Input& in, |
| 63 GeneralizedTime* out) WARN_UNUSED_RESULT; | 76 GeneralizedTime* out) WARN_UNUSED_RESULT; |
| 64 | 77 |
| 65 } // namespace der | 78 } // namespace der |
| 66 | 79 |
| 67 } // namespace net | 80 } // namespace net |
| 68 | 81 |
| 69 #endif // NET_DER_PARSE_VALUES_H_ | 82 #endif // NET_DER_PARSE_VALUES_H_ |
| OLD | NEW |