• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the License); you may
5  *  not use this file except in compliance with the License.
6  *
7  *  http://www.apache.org/licenses/LICENSE-2.0
8  */
9 
10 
11 #ifndef GMSSL_EC_H
12 #define GMSSL_EC_H
13 
14 
15 #include <time.h>
16 #include <string.h>
17 #include <stdint.h>
18 #include <stdlib.h>
19 #include <gmssl/sm2.h>
20 #include <gmssl/oid.h>
21 #include <gmssl/asn1.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /*
28 NamedCurve:
29 	OID_sm2
30 	OID_prime192v1
31 	OID_prime256v1
32 	OID_secp256k1
33 	OID_secp384r1
34 	OID_secp521r1
35 */
36 const char *ec_named_curve_name(int curve);
37 int ec_named_curve_from_name(const char *name);
38 int ec_named_curve_to_der(int curve, uint8_t **out, size_t *outlen);
39 int ec_named_curve_from_der(int *curve, const uint8_t **in, size_t *inlen);
40 
41 /*
42 ECPoint ::= OCTET STRING -- uncompressed point
43 */
44 int ec_point_print(FILE *fp, int fmt, int ind, const char *label, const uint8_t *d, size_t dlen);
45 
46 /*
47 ECPrivateKey ::= SEQUENCE {
48 	version		INTEGER,	-- value MUST be (1)
49 	privateKey	OCTET STRING,	-- big endian encoding of integer
50 	parameters	[0] EXPLICIT OBJECT IDENTIFIER OPTIONAL, -- namedCurve
51 	publicKey	[1] EXPLICIT BIT STRING OPTIONAL -- ECPoint
52 }
53 */
54 
55 enum {
56 	EC_private_key_version = 1,
57 };
58 
59 int ec_private_key_print(FILE *fp, int fmt, int ind, const char *label, const uint8_t *d, size_t dlen);
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 #endif
65