This commit is contained in:
Zhi Guan
2016-06-06 22:04:44 +02:00
parent 2bf25bd29f
commit 2cb43b7f80
142 changed files with 7768 additions and 1678 deletions

View File

@@ -53,7 +53,8 @@
#include <stdio.h>
#include "cryptlib.h"
#ifndef OPENSSL_NO_GMSSL
#ifndef NO_GMSSL
#include <openssl/evp.h>
#include <openssl/objects.h>
#include <openssl/crypto.h>
@@ -61,8 +62,6 @@
#include "modes_lcl.h"
#include <openssl/sms4.h>
#define SMS4_IV_LENGTH SMS4_BLOCK_SIZE
typedef struct {
sms4_key_t ks;
} EVP_SMS4_KEY;
@@ -95,7 +94,7 @@ static int sms4_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len)
{
EVP_SMS4_KEY *sms4_key = (EVP_SMS4_KEY *)ctx->cipher_data;
if (ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) {
CRYPTO_cfb128_1_encrypt(in, out, len, &sms4_key->ks,
ctx->iv, &ctx->num, ctx->encrypt, (block128_f)sms4_encrypt);
@@ -144,7 +143,7 @@ static int sms4_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
CRYPTO_cfb128_8_encrypt(in, out, len, &sms4_key->ks,
ctx->iv, &ctx->num, ctx->encrypt, (block128_f)sms4_encrypt);
return 1;
}
@@ -236,7 +235,7 @@ static int sms4_gcm_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
case EVP_CTRL_COPY:
default:
return -1;
}
}
}
@@ -255,7 +254,7 @@ static int sms4_wrap_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
{
EVP_SMS4_WRAP_CTX *sms4_wrap = ctx->cipher_data;
if (!iv && !key)
return 1;
@@ -337,7 +336,7 @@ static int sms4_wrap_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
NULL, /* get_asn1_parameters() */
NULL, /* ctrl() */
NULL /* app_data */
};
};
const EVP_CIPHER *EVP_sms4_wrap(void)
{