Rizin
unix-like reverse engineering framework and cli tools
zip_crypto_openssl.h File Reference
#include <openssl/evp.h>
#include <openssl/hmac.h>

Go to the source code of this file.

Macros

#define HAVE_SECURE_RANDOM
 
#define _zip_crypto_aes_t   EVP_CIPHER_CTX
 
#define _zip_crypto_hmac_t   HMAC_CTX
 
#define _zip_crypto_hmac(hmac, data, length)   (HMAC_Update((hmac), (data), (length)) == 1)
 
#define _zip_crypto_pbkdf2(key, key_length, salt, salt_length, iterations, output, output_length)   (PKCS5_PBKDF2_HMAC_SHA1((const char *)(key), (key_length), (salt), (salt_length), (iterations), (output_length), (output)))
 

Functions

void _zip_crypto_aes_free (_zip_crypto_aes_t *aes)
 
bool _zip_crypto_aes_encrypt_block (_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out)
 
_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_hmac_free (_zip_crypto_hmac_t *hmac)
 
_zip_crypto_hmac_t_zip_crypto_hmac_new (const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error)
 
bool _zip_crypto_hmac_output (_zip_crypto_hmac_t *hmac, zip_uint8_t *data)
 

Macro Definition Documentation

◆ _zip_crypto_aes_t

#define _zip_crypto_aes_t   EVP_CIPHER_CTX

Definition at line 42 of file zip_crypto_openssl.h.

◆ _zip_crypto_hmac

#define _zip_crypto_hmac (   hmac,
  data,
  length 
)    (HMAC_Update((hmac), (data), (length)) == 1)

Definition at line 49 of file zip_crypto_openssl.h.

◆ _zip_crypto_hmac_t

#define _zip_crypto_hmac_t   HMAC_CTX

Definition at line 43 of file zip_crypto_openssl.h.

◆ _zip_crypto_pbkdf2

#define _zip_crypto_pbkdf2 (   key,
  key_length,
  salt,
  salt_length,
  iterations,
  output,
  output_length 
)    (PKCS5_PBKDF2_HMAC_SHA1((const char *)(key), (key_length), (salt), (salt_length), (iterations), (output_length), (output)))

Definition at line 54 of file zip_crypto_openssl.h.

◆ HAVE_SECURE_RANDOM

#define HAVE_SECURE_RANDOM

Definition at line 37 of file zip_crypto_openssl.h.

Function Documentation

◆ _zip_crypto_aes_encrypt_block()

bool _zip_crypto_aes_encrypt_block ( _zip_crypto_aes_t aes,
const zip_uint8_t in,
zip_uint8_t out 
)

Definition at line 54 of file zip_crypto_commoncrypto.c.

54  {
55  size_t len;
57  return true;
58 }
size_t len
Definition: 6502dis.c:15
const lzma_allocator const uint8_t * in
Definition: block.h:527
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
#define ZIP_CRYPTO_AES_BLOCK_LENGTH
Definition: zip_crypto.h:38

◆ _zip_crypto_aes_free()

void _zip_crypto_aes_free ( _zip_crypto_aes_t aes)

Definition at line 44 of file zip_crypto_commoncrypto.c.

44  {
45  if (aes == NULL) {
46  return;
47  }
48 
49  CCCryptorRelease(aes);
50 }
#define NULL
Definition: cris-opc.c:27

◆ _zip_crypto_aes_new()

_zip_crypto_aes_t* _zip_crypto_aes_new ( const zip_uint8_t key,
zip_uint16_t  key_size,
zip_error_t error 
)

Definition at line 62 of file zip_crypto_commoncrypto.c.

62  {
63  _zip_crypto_aes_t *aes;
64  CCCryptorStatus ret;
65 
66  ret = CCCryptorCreate(kCCEncrypt, kCCAlgorithmAES, kCCOptionECBMode, key, key_size / 8, NULL, &aes);
67 
68  switch (ret) {
69  case kCCSuccess:
70  return aes;
71 
72  case kCCMemoryFailure:
74  return NULL;
75 
76  case kCCParamError:
78  return NULL;
79 
80  default:
82  return NULL;
83  }
84 }
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
Definition: sflib.h:118
#define ZIP_ER_INTERNAL
Definition: zip.h:125
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int)
Definition: zip_error.c:126
#define ZIP_ER_MEMORY
Definition: zip.h:119
#define ZIP_ER_INVAL
Definition: zip.h:123
void error(const char *msg)
Definition: untgz.c:593

◆ _zip_crypto_hmac_free()

void _zip_crypto_hmac_free ( _zip_crypto_hmac_t hmac)

Definition at line 88 of file zip_crypto_commoncrypto.c.

88  {
89  if (hmac == NULL) {
90  return;
91  }
92 
93  _zip_crypto_clear(hmac, sizeof(*hmac));
94  free(hmac);
95 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
#define _zip_crypto_clear(b, l)
Definition: zipint.h:489

◆ _zip_crypto_hmac_new()

_zip_crypto_hmac_t* _zip_crypto_hmac_new ( const zip_uint8_t secret,
zip_uint64_t  secret_length,
zip_error_t error 
)

Definition at line 99 of file zip_crypto_commoncrypto.c.

99  {
100  _zip_crypto_hmac_t *hmac;
101 
102  if ((hmac = (_zip_crypto_hmac_t *)malloc(sizeof(*hmac))) == NULL) {
104  return NULL;
105  }
106 
107  CCHmacInit(hmac, kCCHmacAlgSHA1, secret, secret_length);
108 
109  return hmac;
110 }
void * malloc(size_t size)
Definition: malloc.c:123

◆ _zip_crypto_hmac_output()

bool _zip_crypto_hmac_output ( _zip_crypto_hmac_t hmac,
zip_uint8_t data 
)

Definition at line 174 of file zip_crypto_openssl.c.

174  {
175  unsigned int length;
176 
177  return HMAC_Final(hmac, data, &length) == 1;
178 }
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
Definition: sflib.h:133