OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CRYPTO_OPENSSL_UTIL_H_ | 5 #ifndef CRYPTO_OPENSSL_UTIL_H_ |
6 #define CRYPTO_OPENSSL_UTIL_H_ | 6 #define CRYPTO_OPENSSL_UTIL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "crypto/crypto_export.h" | 12 #include "crypto/crypto_export.h" |
13 | 13 |
14 namespace crypto { | 14 namespace crypto { |
15 | 15 |
16 // Provides a buffer of at least MIN_SIZE bytes, for use when calling OpenSSL's | 16 // Provides a buffer of at least MIN_SIZE bytes, for use when calling OpenSSL's |
17 // SHA256, HMAC, etc functions, adapting the buffer sizing rules to meet those | 17 // SHA256, HMAC, etc functions, adapting the buffer sizing rules to meet those |
18 // of the our base wrapper APIs. | 18 // of our base wrapper APIs. |
19 // This allows the library to write directly to the caller's buffer if it is of | 19 // This allows the library to write directly to the caller's buffer if it is of |
20 // sufficient size, but if not it will write to temporary |min_sized_buffer_| | 20 // sufficient size, but if not it will write to temporary |min_sized_buffer_| |
21 // of required size and then its content is automatically copied out on | 21 // of required size and then its content is automatically copied out on |
22 // destruction, with truncation as appropriate. | 22 // destruction, with truncation as appropriate. |
23 template<int MIN_SIZE> | 23 template<int MIN_SIZE> |
24 class ScopedOpenSSLSafeSizeBuffer { | 24 class ScopedOpenSSLSafeSizeBuffer { |
25 public: | 25 public: |
26 ScopedOpenSSLSafeSizeBuffer(unsigned char* output, size_t output_len) | 26 ScopedOpenSSLSafeSizeBuffer(unsigned char* output, size_t output_len) |
27 : output_(output), | 27 : output_(output), |
28 output_len_(output_len) { | 28 output_len_(output_len) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 private: | 84 private: |
85 const tracked_objects::Location location_; | 85 const tracked_objects::Location location_; |
86 | 86 |
87 DISALLOW_IMPLICIT_CONSTRUCTORS(OpenSSLErrStackTracer); | 87 DISALLOW_IMPLICIT_CONSTRUCTORS(OpenSSLErrStackTracer); |
88 }; | 88 }; |
89 | 89 |
90 } // namespace crypto | 90 } // namespace crypto |
91 | 91 |
92 #endif // CRYPTO_OPENSSL_UTIL_H_ | 92 #endif // CRYPTO_OPENSSL_UTIL_H_ |
OLD | NEW |