SM2 KAP (Key Agreement Protocol), not tested

This commit is contained in:
Zhi Guan
2016-04-07 22:15:41 +02:00
parent ef74cbd1e5
commit 5cc6cfdf22
55 changed files with 3803 additions and 1028 deletions

View File

@@ -49,20 +49,14 @@
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sms4.h"
#include <openssl/sms4.h>
#include <openssl/modes.h>
void sms4_cbc_encrypt(const unsigned char *in, unsigned char *out,
size_t len, sms4_key_t *key,
unsigned char *ivec, int encrypt)
size_t len, const sms4_key_t *key, unsigned char *iv, int enc)
{
if(encrypt)
CRYPTO_cbc128_encrypt(in,out,len,key,ivec,(block128_f)sms4_encrypt);
else
CRYPTO_cbc128_decrypt(in,out,len,key,ivec,(block128_f)sms4_encrypt);
if (enc)
CRYPTO_cbc128_encrypt(in, out, len, key, iv, (block128_f)sms4_encrypt);
else CRYPTO_cbc128_decrypt(in, out, len, key, iv, (block128_f)sms4_encrypt);
}