signature.h
Go to the documentation of this file.
1 /* signature.h
2  *
3  * Copyright (C) 2006-2020 wolfSSL Inc.
4  *
5  * This file is part of wolfSSL.
6  *
7  * wolfSSL is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * wolfSSL is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20  */
21 
27 #ifndef WOLF_CRYPT_SIGNATURE_H
28 #define WOLF_CRYPT_SIGNATURE_H
29 
31 #include <wolfssl/wolfcrypt/hash.h>
33 
34 #ifdef __cplusplus
35  extern "C" {
36 #endif
37 
38 enum wc_SignatureType {
39  WC_SIGNATURE_TYPE_NONE = 0,
40  WC_SIGNATURE_TYPE_ECC = 1,
41  WC_SIGNATURE_TYPE_RSA = 2,
42  WC_SIGNATURE_TYPE_RSA_W_ENC = 3, /* Adds DER header via wc_EncodeSignature */
43 };
44 
45 WOLFSSL_API int wc_SignatureGetSize(enum wc_SignatureType sig_type,
46  const void* key, word32 key_len);
47 
48 WOLFSSL_API int wc_SignatureVerifyHash(
49  enum wc_HashType hash_type, enum wc_SignatureType sig_type,
50  const byte* hash_data, word32 hash_len,
51  const byte* sig, word32 sig_len,
52  const void* key, word32 key_len);
53 
54 WOLFSSL_API int wc_SignatureVerify(
55  enum wc_HashType hash_type, enum wc_SignatureType sig_type,
56  const byte* data, word32 data_len,
57  const byte* sig, word32 sig_len,
58  const void* key, word32 key_len);
59 
60 WOLFSSL_API int wc_SignatureGenerateHash(
61  enum wc_HashType hash_type, enum wc_SignatureType sig_type,
62  const byte* hash_data, word32 hash_len,
63  byte* sig, word32 *sig_len,
64  const void* key, word32 key_len, WC_RNG* rng);
65 WOLFSSL_API int wc_SignatureGenerateHash_ex(
66  enum wc_HashType hash_type, enum wc_SignatureType sig_type,
67  const byte* hash_data, word32 hash_len,
68  byte* sig, word32 *sig_len,
69  const void* key, word32 key_len, WC_RNG* rng, int verify);
70 WOLFSSL_API int wc_SignatureGenerate(
71  enum wc_HashType hash_type, enum wc_SignatureType sig_type,
72  const byte* data, word32 data_len,
73  byte* sig, word32 *sig_len,
74  const void* key, word32 key_len,
75  WC_RNG* rng);
76 WOLFSSL_API int wc_SignatureGenerate_ex(
77  enum wc_HashType hash_type, enum wc_SignatureType sig_type,
78  const byte* data, word32 data_len,
79  byte* sig, word32 *sig_len,
80  const void* key, word32 key_len,
81  WC_RNG* rng, int verify);
82 
83 #ifdef __cplusplus
84  } /* extern "C" */
85 #endif
86 
87 #endif /* WOLF_CRYPT_SIGNATURE_H */
WOLFSSL_API int wc_SignatureGenerate(enum wc_HashType hash_type, enum wc_SignatureType sig_type, const byte *data, word32 data_len, byte *sig, word32 *sig_len, const void *key, word32 key_len, WC_RNG *rng)
This function generates a signature from the data using a key. It first creates a hash of the data th...
Definition: signature.c:447
Definition: random.h:153
WOLFSSL_API int wc_SignatureVerify(enum wc_HashType hash_type, enum wc_SignatureType sig_type, const byte *data, word32 data_len, const byte *sig, word32 sig_len, const void *key, word32 key_len)
This function validates a signature by hashing the data and using the resulting hash and key to verif...
Definition: signature.c:247
WOLFSSL_API int wc_SignatureGetSize(enum wc_SignatureType sig_type, const void *key, word32 key_len)
This function returns the maximum size of the resulting signature.
Definition: signature.c:73