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

Side by Side Diff: crypto/signature_verifier.h

Issue 1882433002: Removing NSS files and USE_OPENSSL flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 months 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
« no previous file with comments | « crypto/signature_creator_nss.cc ('k') | crypto/signature_verifier_nss.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SIGNATURE_VERIFIER_H_ 5 #ifndef CRYPTO_SIGNATURE_VERIFIER_H_
6 #define CRYPTO_SIGNATURE_VERIFIER_H_ 6 #define CRYPTO_SIGNATURE_VERIFIER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "crypto/crypto_export.h" 13 #include "crypto/crypto_export.h"
14 14
15 #if defined(USE_OPENSSL)
16 typedef struct env_md_st EVP_MD; 15 typedef struct env_md_st EVP_MD;
17 typedef struct evp_pkey_ctx_st EVP_PKEY_CTX; 16 typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
18 #else
19 typedef struct HASHContextStr HASHContext;
20 typedef struct SECKEYPublicKeyStr SECKEYPublicKey;
21 typedef struct VFYContextStr VFYContext;
22 #endif
23 17
24 namespace crypto { 18 namespace crypto {
25 19
26 // The SignatureVerifier class verifies a signature using a bare public key 20 // The SignatureVerifier class verifies a signature using a bare public key
27 // (as opposed to a certificate). 21 // (as opposed to a certificate).
28 class CRYPTO_EXPORT SignatureVerifier { 22 class CRYPTO_EXPORT SignatureVerifier {
29 public: 23 public:
30 // The set of supported hash functions. Extend as required. 24 // The set of supported hash functions. Extend as required.
31 enum HashAlgorithm { 25 enum HashAlgorithm {
32 SHA1, 26 SHA1,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 83
90 // Feeds a piece of the data to the signature verifier. 84 // Feeds a piece of the data to the signature verifier.
91 void VerifyUpdate(const uint8_t* data_part, int data_part_len); 85 void VerifyUpdate(const uint8_t* data_part, int data_part_len);
92 86
93 // Concludes a signature verification operation. Returns true if the 87 // Concludes a signature verification operation. Returns true if the
94 // signature is valid. Returns false if the signature is invalid or an 88 // signature is valid. Returns false if the signature is invalid or an
95 // error occurred. 89 // error occurred.
96 bool VerifyFinal(); 90 bool VerifyFinal();
97 91
98 private: 92 private:
99 #if defined(USE_OPENSSL)
100 bool CommonInit(int pkey_type, 93 bool CommonInit(int pkey_type,
101 const EVP_MD* digest, 94 const EVP_MD* digest,
102 const uint8_t* signature, 95 const uint8_t* signature,
103 int signature_len, 96 int signature_len,
104 const uint8_t* public_key_info, 97 const uint8_t* public_key_info,
105 int public_key_info_len, 98 int public_key_info_len,
106 EVP_PKEY_CTX** pkey_ctx); 99 EVP_PKEY_CTX** pkey_ctx);
107 #else
108 static SECKEYPublicKey* DecodePublicKeyInfo(const uint8_t* public_key_info,
109 int public_key_info_len);
110 #endif
111 100
112 void Reset(); 101 void Reset();
113 102
114 std::vector<uint8_t> signature_; 103 std::vector<uint8_t> signature_;
115 104
116 #if defined(USE_OPENSSL)
117 struct VerifyContext; 105 struct VerifyContext;
118 VerifyContext* verify_context_; 106 VerifyContext* verify_context_;
119 #else
120 // Used for all signature types except RSA-PSS.
121 VFYContext* vfy_context_;
122
123 // Used for RSA-PSS signatures.
124 HashAlgorithm hash_alg_;
125 HashAlgorithm mask_hash_alg_;
126 unsigned int salt_len_;
127 SECKEYPublicKey* public_key_;
128 HASHContext* hash_context_;
129 #endif
130 }; 107 };
131 108
132 } // namespace crypto 109 } // namespace crypto
133 110
134 #endif // CRYPTO_SIGNATURE_VERIFIER_H_ 111 #endif // CRYPTO_SIGNATURE_VERIFIER_H_
OLDNEW
« no previous file with comments | « crypto/signature_creator_nss.cc ('k') | crypto/signature_verifier_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698