Delete unused downloads page asset.
[chromium-blink-merge.git] / net / ssl / openssl_ssl_util.h
blob6c886cc1c9cf5d29325f9f62a858eeea9c8ef03e
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_SSL_OPENSSL_SSL_UTIL_H_
6 #define NET_SSL_OPENSSL_SSL_UTIL_H_
8 #include "net/log/net_log.h"
10 namespace crypto {
11 class OpenSSLErrStackTracer;
14 namespace tracked_objects {
15 class Location;
18 namespace net {
20 // Puts a net error, |err|, on the error stack in OpenSSL. The file and line are
21 // extracted from |posted_from|. The function code of the error is left as 0.
22 void OpenSSLPutNetError(const tracked_objects::Location& posted_from, int err);
24 // Utility to construct the appropriate set & clear masks for use the OpenSSL
25 // options and mode configuration functions. (SSL_set_options etc)
26 struct SslSetClearMask {
27 SslSetClearMask();
28 void ConfigureFlag(long flag, bool state);
30 long set_mask;
31 long clear_mask;
34 // Converts an OpenSSL error code into a net error code, walking the OpenSSL
35 // error stack if needed.
37 // Note that |tracer| is not currently used in the implementation, but is passed
38 // in anyway as this ensures the caller will clear any residual codes left on
39 // the error stack.
40 int MapOpenSSLError(int err, const crypto::OpenSSLErrStackTracer& tracer);
42 // Helper struct to store information about an OpenSSL error stack entry.
43 struct OpenSSLErrorInfo {
44 OpenSSLErrorInfo() : error_code(0), file(NULL), line(0) {}
46 uint32_t error_code;
47 const char* file;
48 int line;
51 // Converts an OpenSSL error code into a net error code, walking the OpenSSL
52 // error stack if needed. If a value on the stack is used, the error code and
53 // associated information are returned in |*out_error_info|. Otherwise its
54 // fields are set to 0 and NULL. This function will never return OK, so
55 // SSL_ERROR_ZERO_RETURN must be handled externally.
57 // Note that |tracer| is not currently used in the implementation, but is passed
58 // in anyway as this ensures the caller will clear any residual codes left on
59 // the error stack.
60 int MapOpenSSLErrorWithDetails(int err,
61 const crypto::OpenSSLErrStackTracer& tracer,
62 OpenSSLErrorInfo* out_error_info);
64 // Creates NetLog callback for an OpenSSL error.
65 NetLog::ParametersCallback CreateNetLogOpenSSLErrorCallback(
66 int net_error,
67 int ssl_error,
68 const OpenSSLErrorInfo& error_info);
70 } // namespace net
72 #endif // NET_SSL_OPENSSL_SSL_UTIL_H_