#include <stdlib.h>
#include "zipint.h"
#include "zip_crypto.h"
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <limits.h>
Go to the source code of this file.
|
_zip_crypto_aes_t * | _zip_crypto_aes_new (const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error) |
|
void | _zip_crypto_aes_free (_zip_crypto_aes_t *aes) |
|
_zip_crypto_hmac_t * | _zip_crypto_hmac_new (const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error) |
|
void | _zip_crypto_hmac_free (_zip_crypto_hmac_t *hmac) |
|
bool | _zip_crypto_pbkdf2 (const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, int iterations, zip_uint8_t *output, zip_uint64_t output_length) |
|
ZIP_EXTERN bool | zip_secure_random (zip_uint8_t *buffer, zip_uint16_t length) |
|
◆ _zip_crypto_aes_free()
◆ _zip_crypto_aes_new()
Definition at line 47 of file zip_crypto_mbedtls.c.
55 mbedtls_aes_init(aes);
56 mbedtls_aes_setkey_enc(aes, (
const unsigned char *)
key, (
unsigned int)key_size);
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int)
void * malloc(size_t size)
void error(const char *msg)
References error(), key, malloc(), NULL, ZIP_ER_MEMORY, and zip_error_set().
◆ _zip_crypto_hmac_free()
◆ _zip_crypto_hmac_new()
Definition at line 73 of file zip_crypto_mbedtls.c.
86 mbedtls_md_init(hmac);
88 if (mbedtls_md_setup(hmac, mbedtls_md_info_from_type(MBEDTLS_MD_SHA1), 1) != 0) {
94 if (mbedtls_md_hmac_starts(hmac, (
const unsigned char *)secret, (
size_t)secret_length) != 0) {
References error(), free(), INT_MAX, malloc(), NULL, ZIP_ER_INTERNAL, ZIP_ER_INVAL, ZIP_ER_MEMORY, and zip_error_set().
◆ _zip_crypto_pbkdf2()
Definition at line 116 of file zip_crypto_mbedtls.c.
117 mbedtls_md_context_t sha1_ctx;
120 mbedtls_md_init(&sha1_ctx);
122 if (mbedtls_md_setup(&sha1_ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA1), 1) != 0) {
126 if (
ok && mbedtls_pkcs5_pbkdf2_hmac(&sha1_ctx, (
const unsigned char *)
key, (
size_t)key_length, (
const unsigned char *)salt, (
size_t)salt_length, (
unsigned int)iterations, (
uint32_t)output_length, (
unsigned char *)
output) != 0) {
130 mbedtls_md_free(&sha1_ctx);
References key, ok, and output.
◆ zip_secure_random()
Definition at line 141 of file zip_crypto_mbedtls.c.
143 const unsigned char *pers =
"zip_crypto_mbedtls";
150 mbedtls_entropy_init(&
ctx->entropy);
151 mbedtls_ctr_drbg_init(&
ctx->ctr_drbg);
152 if (mbedtls_ctr_drbg_seed(&
ctx->ctr_drbg, mbedtls_entropy_func, &
ctx->entropy, pers, strlen(pers)) != 0) {
153 mbedtls_ctr_drbg_free(&
ctx->ctr_drbg);
154 mbedtls_entropy_free(&
ctx->entropy);
161 return mbedtls_ctr_drbg_random(&
ctx->ctr_drbg, (
unsigned char *)
buffer, (
size_t)
length) == 0;
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
References free(), length, malloc(), and NULL.