source: azure_iot_hub_f767zi/trunk/wolfssl-4.4.0/wolfssl/wolfcrypt/curve448.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 4.2 KB
Line 
1/* curve448.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
22/* Implemented to: RFC 7748 */
23
24
25#ifndef WOLF_CRYPT_CURVE448_H
26#define WOLF_CRYPT_CURVE448_H
27
28#include <wolfssl/wolfcrypt/types.h>
29
30#ifdef HAVE_CURVE448
31
32#include <wolfssl/wolfcrypt/fe_448.h>
33#include <wolfssl/wolfcrypt/random.h>
34
35#ifdef WOLFSSL_ASYNC_CRYPT
36 #include <wolfssl/wolfcrypt/async.h>
37#endif
38
39#ifdef __cplusplus
40 extern "C" {
41#endif
42
43#define CURVE448_KEY_SIZE 56
44#define CURVE448_PUB_KEY_SIZE 56
45
46
47/* A CURVE448 Key */
48typedef struct curve448_key {
49 byte p[CURVE448_PUB_KEY_SIZE]; /* public key */
50 byte k[CURVE448_KEY_SIZE]; /* private key */
51
52#ifdef WOLFSSL_ASYNC_CRYPT
53 WC_ASYNC_DEV asyncDev;
54#endif
55} curve448_key;
56
57enum {
58 EC448_LITTLE_ENDIAN = 0,
59 EC448_BIG_ENDIAN = 1
60};
61
62WOLFSSL_API
63int wc_curve448_make_key(WC_RNG* rng, int keysize, curve448_key* key);
64
65WOLFSSL_API
66int wc_curve448_shared_secret(curve448_key* private_key,
67 curve448_key* public_key,
68 byte* out, word32* outlen);
69
70WOLFSSL_API
71int wc_curve448_shared_secret_ex(curve448_key* private_key,
72 curve448_key* public_key,
73 byte* out, word32* outlen, int endian);
74
75WOLFSSL_API
76int wc_curve448_init(curve448_key* key);
77
78WOLFSSL_API
79void wc_curve448_free(curve448_key* key);
80
81
82/* raw key helpers */
83WOLFSSL_API
84int wc_curve448_import_private(const byte* priv, word32 privSz,
85 curve448_key* key);
86WOLFSSL_API
87int wc_curve448_import_private_ex(const byte* priv, word32 privSz,
88 curve448_key* key, int endian);
89
90WOLFSSL_API
91int wc_curve448_import_private_raw(const byte* priv, word32 privSz,
92 const byte* pub, word32 pubSz,
93 curve448_key* key);
94WOLFSSL_API
95int wc_curve448_import_private_raw_ex(const byte* priv, word32 privSz,
96 const byte* pub, word32 pubSz,
97 curve448_key* key, int endian);
98WOLFSSL_API
99int wc_curve448_export_private_raw(curve448_key* key, byte* out,
100 word32* outLen);
101WOLFSSL_API
102int wc_curve448_export_private_raw_ex(curve448_key* key, byte* out,
103 word32* outLen, int endian);
104
105WOLFSSL_API
106int wc_curve448_import_public(const byte* in, word32 inLen,
107 curve448_key* key);
108WOLFSSL_API
109int wc_curve448_import_public_ex(const byte* in, word32 inLen,
110 curve448_key* key, int endian);
111WOLFSSL_API
112int wc_curve448_check_public(const byte* pub, word32 pubSz, int endian);
113
114WOLFSSL_API
115int wc_curve448_export_public(curve448_key* key, byte* out, word32* outLen);
116WOLFSSL_API
117int wc_curve448_export_public_ex(curve448_key* key, byte* out,
118 word32* outLen, int endian);
119
120WOLFSSL_API
121int wc_curve448_export_key_raw(curve448_key* key,
122 byte* priv, word32 *privSz,
123 byte* pub, word32 *pubSz);
124WOLFSSL_API
125int wc_curve448_export_key_raw_ex(curve448_key* key,
126 byte* priv, word32 *privSz,
127 byte* pub, word32 *pubSz,
128 int endian);
129/* size helper */
130WOLFSSL_API
131int wc_curve448_size(curve448_key* key);
132
133#ifdef __cplusplus
134 } /* extern "C" */
135#endif
136
137#endif /* HAVE_CURVE448 */
138#endif /* WOLF_CRYPT_CURVE448_H */
139
Note: See TracBrowser for help on using the repository browser.