xref: /aosp_15_r20/external/cronet/third_party/boringssl/src/pki/verify_signed_data.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BSSL_PKI_VERIFY_SIGNED_DATA_H_
6 #define BSSL_PKI_VERIFY_SIGNED_DATA_H_
7 
8 #include <openssl/base.h>
9 #include <openssl/evp.h>
10 #include <openssl/pki/signature_verify_cache.h>
11 
12 #include "signature_algorithm.h"
13 
14 namespace bssl {
15 
16 namespace der {
17 class BitString;
18 class Input;
19 }  // namespace der
20 
21 // Verifies that |signature_value| is a valid signature of |signed_data| using
22 // the algorithm |algorithm| and the public key |public_key|.
23 //
24 //   |algorithm| - The parsed AlgorithmIdentifier
25 //   |signed_data| - The blob of data to verify
26 //   |signature_value| - The BIT STRING for the signature's value
27 //   |public_key| - The parsed (non-null) public key.
28 //
29 // Returns true if verification was successful.
30 [[nodiscard]] OPENSSL_EXPORT bool VerifySignedData(
31     SignatureAlgorithm algorithm, der::Input signed_data,
32     const der::BitString &signature_value, EVP_PKEY *public_key,
33     SignatureVerifyCache *cache);
34 
35 // Same as above overload, only the public key is inputted as an SPKI and will
36 // be parsed internally.
37 [[nodiscard]] OPENSSL_EXPORT bool VerifySignedData(
38     SignatureAlgorithm algorithm, der::Input signed_data,
39     const der::BitString &signature_value, der::Input public_key_spki,
40     SignatureVerifyCache *cache);
41 
42 [[nodiscard]] OPENSSL_EXPORT bool ParsePublicKey(
43     der::Input public_key_spki, bssl::UniquePtr<EVP_PKEY> *public_key);
44 
45 }  // namespace bssl
46 
47 #endif  // BSSL_PKI_VERIFY_SIGNED_DATA_H_
48