mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-07 21:53:41 +08:00
new modules
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#ifndef LIBSM_SMS4_H
|
||||
#define LIBSM_SMS4_H
|
||||
#ifndef HEADER_SMS4_H
|
||||
#define HEADER_SMS4_H
|
||||
|
||||
#define SMS4_KEY_LENGTH 16
|
||||
#define SMS4_BLOCK_SIZE 16
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "openssl/modes.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -20,18 +22,21 @@ typedef struct {
|
||||
void sms4_set_encrypt_key(sms4_key_t *key, const unsigned char *user_key);
|
||||
void sms4_set_decrypt_key(sms4_key_t *key, const unsigned char *user_key);
|
||||
void sms4_encrypt(const unsigned char *in, unsigned char *out, sms4_key_t *key);
|
||||
void sms4_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const sms4_key_t *key,
|
||||
unsigned char *ivec, int encrypt);
|
||||
void sms4_ecb_encrypt(const unsigned char *in, unsigned char *out, const sms4_key_t *key, int encrypt);
|
||||
|
||||
|
||||
void sms4_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,
|
||||
const sms4_key_t *key, unsigned char *ivec, int encrypt);
|
||||
void sms4_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const sms4_key_t *key,
|
||||
size_t length, const sms4_key_t *key,
|
||||
unsigned char *ivec, int *num, int encrypt);
|
||||
void sms4_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const sms4_key_t *key,
|
||||
unsigned char ivec[SMS4_BLOCK_SIZE],
|
||||
unsigned int *num);
|
||||
void sms4_ecb_encrypt(const unsigned char *in, unsigned char *out, const sms4_key_t *key, int encrypt);
|
||||
|
||||
#define sms4_decrypt(in,out,key) sms4_encrypt(in,out,key)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
void sms4_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t len, const sms4_key_t *key,
|
||||
unsigned char *ivec, int encrypt) {
|
||||
unsigned char *ivec, int encrypt)
|
||||
{
|
||||
if(encrypt)
|
||||
CRYPTO_cbc128_encrypt(in,out,len,key,ivec,(block128_f)sms4_encrypt);
|
||||
else
|
||||
|
||||
@@ -12,4 +12,4 @@ void sms4_ecb_encrypt(const unsigned char *in, unsigned char *out, const sms4_ke
|
||||
sms4_decrypt(in, out, key);
|
||||
}
|
||||
|
||||
//sms4_decrypt = sms4_encrypt, but the key is in reverse order
|
||||
//sms4_decrypt = sms4_encrypt, but the key is in reverse order
|
||||
|
||||
Reference in New Issue
Block a user