luat_soc_sdk_2024 V1.0
luat_crypto.h
浏览该文件的文档.
1#ifndef LUAT_CRYPTO_H
2#define LUAT_CRYPTO_H
3#include "luat_base.h"
4
5#define LUAT_CRYPTO_AES_ECB 1
6#define LUAT_CRYPTO_AES_CBC 2
7#define LUAT_CRYPTO_AES_CTR 3
8#define LUAT_CRYPTO_AES_CFB 4
9#define LUAT_CRYPTO_AES_OFB 5
10
11#define LUAT_CRYPTO_AES_PAD_ZERO 1
12#define LUAT_CRYPTO_AES_PAD_5 2
13#define LUAT_CRYPTO_AES_PAD_7 3
14
15typedef struct
16{
18 size_t key_len;
19 void* ctx;
32int luat_crypto_trng(char* buff, size_t len);
38int luat_crypto_md5_simple(const char* str, size_t str_size, void* out_ptr);
46int luat_crypto_hmac_md5_simple(const char* str, size_t str_size, const char* mac, size_t mac_size, void* out_ptr);
47
53int luat_crypto_sha1_simple(const char* str, size_t str_size, void* out_ptr);
61int luat_crypto_hmac_sha1_simple(const char* str, size_t str_size, const char* mac, size_t mac_size, void* out_ptr);
67int luat_crypto_sha256_simple(const char* str, size_t str_size, void* out_ptr);
75int luat_crypto_hmac_sha256_simple(const char* str, size_t str_size, const char* mac, size_t mac_size, void* out_ptr) ;
81int luat_crypto_sha512_simple(const char* str, size_t str_size, void* out_ptr) ;
89int luat_crypto_hmac_sha512_simple(const char* str, size_t str_size, const char* mac, size_t mac_size, void* out_ptr) ;
99int luat_crypto_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen ) ;
109int luat_crypto_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen ) ;
111int luat_crypto_cipher_list(const char** list, size_t* len);
112int luat_crypto_cipher_suites(const char** list, size_t* len);
113
114int luat_crypto_md(const char* md, const char* str, size_t str_size, void* out_ptr, const char* key, size_t key_len);
115int luat_crypto_md_file(const char* md, void* out_ptr, const char* key, size_t key_len, const char* path);
116
117int luat_crypto_md_init(const char* md, const char* key, luat_crypt_stream_t *stream);
118int luat_crypto_md_update(const char* str, size_t str_size, luat_crypt_stream_t *stream);
119int luat_crypto_md_finish(void* out_ptr, luat_crypt_stream_t *stream);
120
122{
123 const char* cipher;
124 const char* pad;
125 const char* str;
126 const char* key;
127 const char* iv;
128
130 size_t pad_size;
131 size_t str_size;
132 size_t key_size;
133 size_t iv_size;
134 char* outbuff;
135 size_t outlen;
136 uint8_t flags;
138
140
141#endif
int luat_crypto_sha1_simple(const char *str, size_t str_size, void *out_ptr)
计算sha1值
int luat_crypto_hmac_sha256_simple(const char *str, size_t str_size, const char *mac, size_t mac_size, void *out_ptr)
计算hmac_sha256值
int luat_crypto_hmac_md5_simple(const char *str, size_t str_size, const char *mac, size_t mac_size, void *out_ptr)
计算hmac_md5值
int luat_crypto_trng(char *buff, size_t len)
生成随机数
int luat_crypto_sha512_simple(const char *str, size_t str_size, void *out_ptr)
计算sha512值
int luat_crypto_base64_encode(unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen)
BASE64加密
int luat_crypto_hmac_sha512_simple(const char *str, size_t str_size, const char *mac, size_t mac_size, void *out_ptr)
计算hmac_sha512值
int luat_crypto_hmac_sha1_simple(const char *str, size_t str_size, const char *mac, size_t mac_size, void *out_ptr)
计算hmac_sha1值
int luat_crypto_base64_decode(unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen)
BASE64解密
int luat_crypto_md5_simple(const char *str, size_t str_size, void *out_ptr)
计算md5值
int luat_crypto_sha256_simple(const char *str, size_t str_size, void *out_ptr)
计算sha256值
int luat_crypto_cipher_list(const char **list, size_t *len)
int luat_crypto_cipher_suites(const char **list, size_t *len)
int luat_crypto_cipher_xxx(luat_crypto_cipher_ctx_t *cctx)
int luat_crypto_md(const char *md, const char *str, size_t str_size, void *out_ptr, const char *key, size_t key_len)
int luat_crypto_md_finish(void *out_ptr, luat_crypt_stream_t *stream)
int luat_crypto_md_init(const char *md, const char *key, luat_crypt_stream_t *stream)
int luat_crypto_md_update(const char *str, size_t str_size, luat_crypt_stream_t *stream)
int luat_crypto_md_file(const char *md, void *out_ptr, const char *key, size_t key_len, const char *path)
struct luat_crypto_cipher_ctx luat_crypto_cipher_ctx_t