libcamera v0.1.0+127-8e215127-dirty (2023-12-02T01:06:12+00:00)
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
15struct evp_pkey_st;
16#elif HAVE_GNUTLS
17struct gnutls_pubkey_st;
18#endif
19
20namespace libcamera {
21
22class PubKey
23{
24public:
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
31private:
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 */
Public key wrapper for signature verification.
Definition: pub_key.h:23
PubKey(Span< const uint8_t > key)
Construct a PubKey from key data.
Definition: pub_key.cpp:38
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
Top-level libcamera namespace.
Definition: backtrace.h:17