Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: base/openssl_util.h

Issue 4691003: Implement symmetric key for openssl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix windows build Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 BASE_OPENNSSL_UTIL_H_ 5 #ifndef BASE_OPENSSL_UTIL_H_
6 #define BASE_OPENNSSL_UTIL_H_ 6 #define BASE_OPENSSL_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/tracked.h"
10 11
11 namespace base { 12 namespace base {
12 13
13 // Provides a buffer of at least MIN_SIZE bytes, for use when calling OpenSSL's 14 // Provides a buffer of at least MIN_SIZE bytes, for use when calling OpenSSL's
14 // SHA256, HMAC, etc functions, adapting the buffer sizing rules to meet those 15 // SHA256, HMAC, etc functions, adapting the buffer sizing rules to meet those
15 // of the our base wrapper APIs. 16 // of the our base wrapper APIs.
16 // This allows the library to write directly to the caller's buffer if it is of 17 // This allows the library to write directly to the caller's buffer if it is of
17 // sufficient size, but if not it will write to temporary |min_sized_buffer_| 18 // sufficient size, but if not it will write to temporary |min_sized_buffer_|
18 // of required size and then its content is automatically copied out on 19 // of required size and then its content is automatically copied out on
19 // destruction, with truncation as appropriate. 20 // destruction, with truncation as appropriate.
(...skipping 19 matching lines...) Expand all
39 40
40 private: 41 private:
41 // Pointer to the caller's data area and it's associated size, where data 42 // Pointer to the caller's data area and it's associated size, where data
42 // written via safe_buffer() will [eventually] end up. 43 // written via safe_buffer() will [eventually] end up.
43 unsigned char* output_; 44 unsigned char* output_;
44 size_t output_len_; 45 size_t output_len_;
45 46
46 // Temporary buffer writen into in the case where the caller's 47 // Temporary buffer writen into in the case where the caller's
47 // buffer is not of sufficient size. 48 // buffer is not of sufficient size.
48 unsigned char min_sized_buffer_[MIN_SIZE]; 49 unsigned char min_sized_buffer_[MIN_SIZE];
50
51 DISALLOW_COPY_AND_ASSIGN(ScopedOpenSSLSafeSizeBuffer);
52 };
53
54 // Drains the OpenSSL ERR_get_error stack. On a debug build the error codes
55 // are send to VLOG(1), on a release build they are disregarded.
56 void ClearERRStack();
wtc 2010/11/11 23:39:15 IMPORTANT: this function name should include "Open
joth 2010/11/12 12:15:53 Done.
57
58 // Put an instance of this class on the call stack to automatically clear the
59 // OpenSSL error stack on exit of your function.
60 class ScopedERRStackClearer {
61 public:
62 ScopedERRStackClearer() {}
63 ~ScopedERRStackClearer() { ClearERRStack(); }
64
65 private:
66 DISALLOW_COPY_AND_ASSIGN(ScopedERRStackClearer);
49 }; 67 };
50 68
51 } // namespace base 69 } // namespace base
52 70
53 #endif // BASE_NSS_UTIL_H_ 71 #endif // BASE_OPENSSL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698