Skip to content

Commit a5b727c

Browse files
committed
bug fix
err, cbcmac
1 parent e299320 commit a5b727c

5 files changed

Lines changed: 10 additions & 60 deletions

File tree

crypto/cbcmac/cbcmac.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <stdio.h>
22
#include <stdlib.h>
3+
#include <string.h>
34
#include <openssl/err.h>
45
#include <openssl/evp.h>
56
#include <openssl/cbcmac.h>
@@ -53,7 +54,7 @@ int CBCMAC_CTX_copy(CBCMAC_CTX *to, const CBCMAC_CTX *from)
5354
int CBCMAC_Init(CBCMAC_CTX *ctx, const void *key, size_t keylen,
5455
const EVP_CIPHER *cipher, ENGINE *eng)
5556
{
56-
int i, block_size;
57+
int block_size;
5758

5859
if (!EVP_EncryptInit_ex(&ctx->cipher_ctx, cipher, eng, key, NULL)) {
5960
CBCMACerr(CBCMAC_F_CBCMAC_INIT, CBCMAC_R_CIPHER_CTX_INIT_FAILED);
@@ -123,14 +124,14 @@ int CBCMAC_Update(CBCMAC_CTX *ctx, const void *data, size_t datalen)
123124

124125
int CBCMAC_Final(CBCMAC_CTX *ctx, unsigned char *out, size_t *outlen)
125126
{
126-
int i;
127+
int i, len;
127128
int block_size = EVP_CIPHER_CTX_block_size(&(ctx->cipher_ctx));
128129

129130
if (ctx->worklen) {
130131
for (i = ctx->worklen; i < block_size; i++) {
131132
ctx->workspace[i] = ctx->cbcstate[i];
132133
}
133-
if (!EVP_EncryptUpdate(&(ctx->cipher_ctx), out, outlen, ctx->workspace, block_size)) {
134+
if (!EVP_EncryptUpdate(&(ctx->cipher_ctx), out, &len, ctx->workspace, block_size)) {
134135
CBCMACerr(CBCMAC_F_CBCMAC_FINAL, ERR_R_EVP_LIB);
135136
return 0;
136137
}
@@ -141,6 +142,7 @@ int CBCMAC_Final(CBCMAC_CTX *ctx, unsigned char *out, size_t *outlen)
141142
}
142143
}
143144

145+
*outlen = block_size;
144146
return 1;
145147
}
146148

crypto/ec/ec_pmeth.c

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -250,38 +250,8 @@ static int pkey_ec_verify(EVP_PKEY_CTX *ctx,
250250
return ret;
251251
}
252252

253-
static int int_update(EVP_MD_CTX *ctx, const void *data, size_t count)
254-
{
255-
if (!EVP_DigestUpdate(ctx, data, count))
256-
return 0;
257-
return 1;
258-
}
259-
260253
static int pkey_ec_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
261254
{
262-
EC_PKEY_CTX *dctx = ctx->data;
263-
EC_KEY *ec_key = ctx->pkey->pkey.ec;
264-
const EVP_MD *md = EVP_sm3();
265-
unsigned char zid[EVP_MAX_MD_SIZE];
266-
unsigned int zidlen = sizeof(zid);
267-
268-
//FIXME: it is wrong to do it here!
269-
#if 0
270-
if (dctx->sign_type == NID_sm_scheme) {
271-
if (!SM2_compute_id_digest(md, zid, &zidlen, ec_key)) {
272-
ECerr(EC_F_PKEY_EC_SIGNCTX_INIT, ERR_R_SM2_LIB);
273-
return 0;
274-
}
275-
276-
mctx->update = int_update;
277-
278-
if (!mctx->update(mctx, zid, zidlen)) {
279-
ECerr(EC_F_PKEY_EC_SIGNCTX_INIT, ERR_R_EVP_LIB);
280-
return 0;
281-
}
282-
}
283-
#endif
284-
285255
return 1;
286256
}
287257

@@ -324,29 +294,7 @@ static int pkey_ec_signctx(EVP_PKEY_CTX *ctx,
324294

325295
static int pkey_ec_verifyctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
326296
{
327-
int ret = 0;
328-
EC_PKEY_CTX *dctx = ctx->data;
329-
EC_KEY *ec_key = ctx->pkey->pkey.ec;
330-
const EVP_MD *md = EVP_sm3(); // FIXME: we need to get md from somewhere
331-
unsigned char zid[EVP_MAX_MD_SIZE];
332-
unsigned int zidlen;
333-
334-
#if 0
335-
if (dctx->sign_type == NID_sm_scheme) {
336-
337-
zidlen = sizeof(zid);
338-
if (!SM2_compute_id_digest(md, zid, &zidlen, ec_key)) {
339-
goto end;
340-
}
341-
if (!mctx->update(mctx, zid, zidlen)) {
342-
goto end;
343-
}
344-
}
345-
#endif
346-
347-
ret = 1;
348-
end:
349-
return ret;
297+
return 1;
350298
}
351299

352300
static int pkey_ec_verifyctx(EVP_PKEY_CTX *ctx,

crypto/err/err_all.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110

111111
#ifndef NO_GMSSL
112112
# include <openssl/sm2.h>
113-
# include <openssl/skf.h>
113+
# include <openssl/skf_ex.h>
114114
# include <openssl/cpk.h>
115115
# include <openssl/ecies.h>
116116
# include <openssl/cbcmac.h>

crypto/opensslv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ extern "C" {
3232
*/
3333
# define OPENSSL_VERSION_NUMBER 0x10201000L
3434
# ifdef OPENSSL_FIPS
35-
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2d-fips 9 Jul 2015"
35+
# define OPENSSL_VERSION_TEXT "GmSSL 1.3.0 - OpenSSL 1.0.2d-fips 9 Jul 2015"
3636
# else
37-
# define OPENSSL_VERSION_TEXT "GmSSL 1.2.2 (OpenSSL 1.0.2d)"
37+
# define OPENSSL_VERSION_TEXT "GmSSL 1.3.0 - OpenSSL 1.0.2d"
3838
# endif
3939
# define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
4040

crypto/sms4/sms4_enc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
void sms4_encrypt(const unsigned char *in, unsigned char *out, const sms4_key_t *key)
6868
{
69-
uint32_t *rk = key->rk;
69+
const uint32_t *rk = key->rk;
7070
uint32_t x0, x1, x2, x3, x4;
7171

7272
x0 = GET32(in );

0 commit comments

Comments
 (0)