mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
AppleM1: Update openssl to v1.1.1l
This commit is contained in:
parent
1fe12b8e8c
commit
b787656eea
990 changed files with 13406 additions and 18710 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017 Ribose Inc. All Rights Reserved.
|
||||
* Ported from Ribose contributions from Botan.
|
||||
*
|
||||
|
@ -9,9 +9,9 @@
|
|||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "internal/sm2.h"
|
||||
#include "internal/sm2err.h"
|
||||
#include "internal/ec_int.h" /* ecdh_KDF_X9_63() */
|
||||
#include "crypto/sm2.h"
|
||||
#include "crypto/sm2err.h"
|
||||
#include "crypto/ec.h" /* ecdh_KDF_X9_63() */
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/bn.h>
|
||||
|
@ -61,29 +61,20 @@ static size_t ec_field_size(const EC_GROUP *group)
|
|||
return field_size;
|
||||
}
|
||||
|
||||
int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,
|
||||
size_t *pt_size)
|
||||
int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size)
|
||||
{
|
||||
const size_t field_size = ec_field_size(EC_KEY_get0_group(key));
|
||||
const int md_size = EVP_MD_size(digest);
|
||||
size_t overhead;
|
||||
struct SM2_Ciphertext_st *sm2_ctext = NULL;
|
||||
|
||||
if (md_size < 0) {
|
||||
SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_DIGEST);
|
||||
return 0;
|
||||
}
|
||||
if (field_size == 0) {
|
||||
SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_FIELD);
|
||||
return 0;
|
||||
}
|
||||
sm2_ctext = d2i_SM2_Ciphertext(NULL, &ct, ct_size);
|
||||
|
||||
overhead = 10 + 2 * field_size + (size_t)md_size;
|
||||
if (msg_len <= overhead) {
|
||||
if (sm2_ctext == NULL) {
|
||||
SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_ENCODING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*pt_size = msg_len - overhead;
|
||||
*pt_size = sm2_ctext->C2->length;
|
||||
SM2_Ciphertext_free(sm2_ctext);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -303,6 +294,10 @@ int sm2_decrypt(const EC_KEY *key,
|
|||
C2 = sm2_ctext->C2->data;
|
||||
C3 = sm2_ctext->C3->data;
|
||||
msg_len = sm2_ctext->C2->length;
|
||||
if (*ptext_len < (size_t)msg_len) {
|
||||
SM2err(SM2_F_SM2_DECRYPT, SM2_R_BUFFER_TOO_SMALL);
|
||||
goto done;
|
||||
}
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*/
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include "internal/sm2err.h"
|
||||
#include "crypto/sm2err.h"
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2006-2021 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
@ -11,9 +11,9 @@
|
|||
#include <openssl/asn1t.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/evp.h>
|
||||
#include "internal/evp_int.h"
|
||||
#include "internal/sm2.h"
|
||||
#include "internal/sm2err.h"
|
||||
#include "crypto/evp.h"
|
||||
#include "crypto/sm2.h"
|
||||
#include "crypto/sm2err.h"
|
||||
|
||||
/* EC pkey context structure */
|
||||
|
||||
|
@ -151,7 +151,7 @@ static int pkey_sm2_decrypt(EVP_PKEY_CTX *ctx,
|
|||
const EVP_MD *md = (dctx->md == NULL) ? EVP_sm3() : dctx->md;
|
||||
|
||||
if (out == NULL) {
|
||||
if (!sm2_plaintext_size(ec, md, inlen, outlen))
|
||||
if (!sm2_plaintext_size(in, inlen, outlen))
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
|
@ -220,6 +220,10 @@ static int pkey_sm2_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
|||
*(size_t *)p2 = smctx->id_len;
|
||||
return 1;
|
||||
|
||||
case EVP_PKEY_CTRL_DIGESTINIT:
|
||||
/* nothing to be inited, this is to suppress the error... */
|
||||
return 1;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017 Ribose Inc. All Rights Reserved.
|
||||
* Ported from Ribose contributions from Botan.
|
||||
*
|
||||
|
@ -9,9 +9,9 @@
|
|||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "internal/sm2.h"
|
||||
#include "internal/sm2err.h"
|
||||
#include "internal/ec_int.h" /* ec_group_do_inverse_ord() */
|
||||
#include "crypto/sm2.h"
|
||||
#include "crypto/sm2err.h"
|
||||
#include "crypto/ec.h" /* ec_group_do_inverse_ord() */
|
||||
#include "internal/numbers.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
|
@ -313,12 +313,12 @@ static int sm2_sig_verify(const EC_KEY *key, const ECDSA_SIG *sig,
|
|||
|
||||
/*
|
||||
* B1: verify whether r' in [1,n-1], verification failed if not
|
||||
* B2: vefify whether s' in [1,n-1], verification failed if not
|
||||
* B2: verify whether s' in [1,n-1], verification failed if not
|
||||
* B3: set M'~=ZA || M'
|
||||
* B4: calculate e'=Hv(M'~)
|
||||
* B5: calculate t = (r' + s') modn, verification failed if t=0
|
||||
* B6: calculate the point (x1', y1')=[s']G + [t]PA
|
||||
* B7: calculate R=(e'+x1') modn, verfication pass if yes, otherwise failed
|
||||
* B7: calculate R=(e'+x1') modn, verification pass if yes, otherwise failed
|
||||
*/
|
||||
|
||||
ECDSA_SIG_get0(sig, &r, &s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue