blob: 189843820a0e04f3f98b2ef86f73290cbb50a162 [file] [log] [blame]
Alexandru Gagniuc98198832021-07-29 11:47:15 -05001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (c) 2020, Alexandru Gagniuc <mr.nuke.me@gmail.com>
4 */
5
6#include <dm/device.h>
7
8/**
9 * struct ecdsa_public_key - ECDSA public key properties
10 *
11 * The struct has pointers to the (x, y) curve coordinates to an ECDSA public
12 * key, as well as the name of the ECDSA curve. The size of the key is inferred
13 * from the 'curve_name'
14 */
15struct ecdsa_public_key {
16 const char *curve_name; /* Name of curve, e.g. "prime256v1" */
17 const void *x; /* x coordinate of public key */
18 const void *y; /* y coordinate of public key */
19 unsigned int size_bits; /* key size in bits, derived from curve name */
20};
21
22struct ecdsa_ops {
23 /**
24 * Verify signature of hash against given public key
25 *
26 * @dev: ECDSA Device
27 * @pubkey: ECDSA public key
28 * @hash: Hash of binary image
29 * @hash_len: Length of hash in bytes
30 * @signature: Signature in a raw (R, S) point pair
31 * @sig_len: Length of signature in bytes
32 *
33 * This function verifies that the 'signature' of the given 'hash' was
34 * signed by the private key corresponding to 'pubkey'.
35 */
36 int (*verify)(struct udevice *dev, const struct ecdsa_public_key *pubkey,
37 const void *hash, size_t hash_len,
38 const void *signature, size_t sig_len);
39};