libcamera  v0.0.0
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 #ifndef __LIBCAMERA_INTERNAL_PUB_KEY_H__
8 #define __LIBCAMERA_INTERNAL_PUB_KEY_H__
9 
10 #include <stdint.h>
11 
12 #include <libcamera/span.h>
13 
14 #if HAVE_GNUTLS
15 struct gnutls_pubkey_st;
16 #endif
17 
18 namespace libcamera {
19 
20 class PubKey
21 {
22 public:
23  PubKey(Span<const uint8_t> key);
24  ~PubKey();
25 
26  bool isValid() const { return valid_; }
27  bool verify(Span<const uint8_t> data, Span<const uint8_t> sig) const;
28 
29 private:
30  bool valid_;
31 #if HAVE_GNUTLS
32  struct gnutls_pubkey_st *pubkey_;
33 #endif
34 };
35 
36 } /* namespace libcamera */
37 
38 #endif /* __LIBCAMERA_INTERNAL_PUB_KEY_H__ */
Public key wrapper for signature verification.
Definition: pub_key.h:21
PubKey(Span< const uint8_t > key)
Construct a PubKey from key data.
Definition: pub_key.cpp:33
bool verify(Span< const uint8_t > data, Span< const uint8_t > sig) const
Verify signature on data.
Definition: pub_key.cpp:76
bool isValid() const
Check is the public key is valid.
Definition: pub_key.h:26