Skip to content

Commit fb47201

Browse files
committed
Add ECRS module
1 parent 258e44e commit fb47201

18 files changed

Lines changed: 6282 additions & 5422 deletions

File tree

Configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ $config{sdirs} = [
314314
"cms", "ts", "srp", "cmac", "ct", "async", "kdf",
315315
"sm3", "base58", "sms4", "zuc", "serpent", "speck", "kdf2", "ffx", "otp",
316316
"ecies", "sm2", "cpk", "paillier", "ec2", "sm9", "bfibe", "bb1ibe",
317-
"gmapi", "skf", "sdf", "saf", "sof",
317+
"gmapi", "skf", "sdf", "saf", "sof", "ecrs"
318318
];
319319

320320
# Known TLS and DTLS protocols
@@ -417,6 +417,7 @@ my @disablables = (
417417
"ecies",
418418
"ffx",
419419
"sm2",
420+
"ecrs",
420421
"paillier",
421422
"cpk",
422423
"otp",

crypto/ecrs/build.info

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
LIBS=../../libcrypto
2+
SOURCE[../../libcrypto]=ecrs_err.c ecrs_asn1.c ecrs_lib.c

crypto/ecrs/ecrs_asn1.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* ====================================================================
2+
* Copyright (c) 2014 - 2019 The GmSSL Project. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in
13+
* the documentation and/or other materials provided with the
14+
* distribution.
15+
*
16+
* 3. All advertising materials mentioning features or use of this
17+
* software must display the following acknowledgment:
18+
* "This product includes software developed by the GmSSL Project.
19+
* (http://gmssl.org/)"
20+
*
21+
* 4. The name "GmSSL Project" must not be used to endorse or promote
22+
* products derived from this software without prior written
23+
* permission. For written permission, please contact
24+
25+
*
26+
* 5. Products derived from this software may not be called "GmSSL"
27+
* nor may "GmSSL" appear in their names without prior written
28+
* permission of the GmSSL Project.
29+
*
30+
* 6. Redistributions of any form whatsoever must retain the following
31+
* acknowledgment:
32+
* "This product includes software developed by the GmSSL Project
33+
* (http://gmssl.org/)"
34+
*
35+
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
36+
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
39+
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46+
* OF THE POSSIBILITY OF SUCH DAMAGE.
47+
* ====================================================================
48+
*/
49+
50+
#include <openssl/asn1.h>
51+
#include <openssl/asn1t.h>
52+
#include <openssl/ecrs.h>
53+
#include "./ecrs_lcl.h"
54+
55+
ASN1_SEQUENCE(ECRS_SIG) = {
56+
ASN1_SIMPLE(ECRS_SIG, s, BIGNUM),
57+
ASN1_SEQUENCE_OF(ECRS_SIG, c, BIGNUM),
58+
} ASN1_SEQUENCE_END(ECRS_SIG)
59+
IMPLEMENT_ASN1_FUNCTIONS(ECRS_SIG)
60+
IMPLEMENT_ASN1_DUP_FUNCTION(ECRS_SIG)
61+
62+
int ECRS_size(const EC_KEY *ec_key, int n)
63+
{
64+
return 128 * n;
65+
}

crypto/ecrs/ecrs_err.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Generated by util/mkerr.pl DO NOT EDIT
3+
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
4+
*
5+
* Licensed under the OpenSSL license (the "License"). You may not use
6+
* this file except in compliance with the License. You can obtain a copy
7+
* in the file LICENSE in the source distribution or at
8+
* https://www.openssl.org/source/license.html
9+
*/
10+
11+
#include <stdio.h>
12+
#include <openssl/err.h>
13+
#include <openssl/ecrs.h>
14+
15+
/* BEGIN ERROR CODES */
16+
#ifndef OPENSSL_NO_ERR
17+
18+
# define ERR_FUNC(func) ERR_PACK(ERR_LIB_ECRS,func,0)
19+
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_ECRS,0,reason)
20+
21+
static ERR_STRING_DATA ECRS_str_functs[] = {
22+
{ERR_FUNC(ECRS_F_ECRS_DO_SIGN), "ECRS_do_sign"},
23+
{ERR_FUNC(ECRS_F_ECRS_DO_VERIFY), "ECRS_do_verify"},
24+
{ERR_FUNC(ECRS_F_ECRS_SIGN), "ECRS_sign"},
25+
{ERR_FUNC(ECRS_F_ECRS_VERIFY), "ECRS_verify"},
26+
{0, NULL}
27+
};
28+
29+
static ERR_STRING_DATA ECRS_str_reasons[] = {
30+
{ERR_REASON(ECRS_R_EC_KEY_NOT_MATCH), "ec key not match"},
31+
{ERR_REASON(ECRS_R_INVALID_DIGEST_ALGOR), "invalid digest algor"},
32+
{ERR_REASON(ECRS_R_NO_SIGNING_KEY), "no signing key"},
33+
{ERR_REASON(ECRS_R_PARSE_SIGNATURE_FAILURE), "parse signature failure"},
34+
{ERR_REASON(ECRS_R_PUBLIC_KEYS_NOT_MATCH), "public keys not match"},
35+
{ERR_REASON(ECRS_R_PUBLIC_KEYS_NOT_MATCH_SIG),
36+
"public keys not match sig"},
37+
{0, NULL}
38+
};
39+
40+
#endif
41+
42+
int ERR_load_ECRS_strings(void)
43+
{
44+
#ifndef OPENSSL_NO_ERR
45+
46+
if (ERR_func_error_string(ECRS_str_functs[0].error) == NULL) {
47+
ERR_load_strings(0, ECRS_str_functs);
48+
ERR_load_strings(0, ECRS_str_reasons);
49+
}
50+
#endif
51+
return 1;
52+
}

crypto/ecrs/ecrs_lcl.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2015 - 2019 The GmSSL Project. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in
13+
* the documentation and/or other materials provided with the
14+
* distribution.
15+
*
16+
* 3. All advertising materials mentioning features or use of this
17+
* software must display the following acknowledgment:
18+
* "This product includes software developed by the GmSSL Project.
19+
* (http://gmssl.org/)"
20+
*
21+
* 4. The name "GmSSL Project" must not be used to endorse or promote
22+
* products derived from this software without prior written
23+
* permission. For written permission, please contact
24+
25+
*
26+
* 5. Products derived from this software may not be called "GmSSL"
27+
* nor may "GmSSL" appear in their names without prior written
28+
* permission of the GmSSL Project.
29+
*
30+
* 6. Redistributions of any form whatsoever must retain the following
31+
* acknowledgment:
32+
* "This product includes software developed by the GmSSL Project
33+
* (http://gmssl.org/)"
34+
*
35+
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
36+
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
39+
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46+
* OF THE POSSIBILITY OF SUCH DAMAGE.
47+
*/
48+
49+
#include <openssl/bn.h>
50+
#include <openssl/stack.h>
51+
52+
struct ECRS_SIG_st {
53+
BIGNUM *s;
54+
STACK_OF(BIGNUM) *c;
55+
};
56+

0 commit comments

Comments
 (0)