libcamera  v0.2.0+85-1c5830a9
Supporting cameras in Linux since 2019
pub_key.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2020, Google Inc.
4  *
5  * pub_key.h - Public key signature verification
6  */
7 
8 #pragma once
9 
10 #include <stdint.h>
11 
12 #include <libcamera/base/span.h>
13 
14 #if HAVE_CRYPTO
15 struct evp_pkey_st;
16 #elif HAVE_GNUTLS
17 struct gnutls_pubkey_st;
18 #endif
19 
20 namespace libcamera {
21 
22 class PubKey
23 {
24 public:
25  PubKey(Span<const uint8_t> key);
26  ~PubKey();
27 
28  bool isValid() const { return valid_; }
29  bool verify(Span<const uint8_t> data, Span<const uint8_t> sig) const;
30 
31 private:
32  bool valid_;
33 #if HAVE_CRYPTO
34  struct evp_pkey_st *pubkey_;
35 #elif HAVE_GNUTLS
36  struct gnutls_pubkey_st *pubkey_;
37 #endif
38 };
39 
40 } /* namespace libcamera */
Top-level libcamera namespace.
Definition: backtrace.h:17
bool verify(Span< const uint8_t > data, Span< const uint8_t > sig) const
Verify signature on data.
Definition: pub_key.cpp:90
bool isValid() const
Check is the public key is valid.
Definition: pub_key.h:28
Public key wrapper for signature verification.
Definition: pub_key.h:22
PubKey(Span< const uint8_t > key)
Construct a PubKey from key data.
Definition: pub_key.cpp:38