Rizin
unix-like reverse engineering framework and cli tools
zip_crypto_gnutls.h File Reference
#include <nettle/aes.h>
#include <nettle/pbkdf2.h>
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>

Go to the source code of this file.

Classes

struct  _zip_crypto_aes_t
 

Macros

#define HAVE_SECURE_RANDOM
 
#define _zip_crypto_hmac_t   gnutls_hmac_hd_t
 
#define _zip_crypto_hmac(hmac, data, length)   (gnutls_hmac(*(hmac), (data), (length)) == 0)
 
#define _zip_crypto_hmac_output(hmac, data)   (gnutls_hmac_output(*(hmac), (data)), true)
 
#define _zip_crypto_pbkdf2(key, key_length, salt, salt_length, iterations, output, output_length)   (pbkdf2_hmac_sha1((key_length), (key), (iterations), (salt_length), (salt), (output_length), (output)), true)
 

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)
 

Macro Definition Documentation

◆ _zip_crypto_hmac

#define _zip_crypto_hmac (   hmac,
  data,
  length 
)    (gnutls_hmac(*(hmac), (data), (length)) == 0)

Definition at line 61 of file zip_crypto_gnutls.h.

◆ _zip_crypto_hmac_output

#define _zip_crypto_hmac_output (   hmac,
  data 
)    (gnutls_hmac_output(*(hmac), (data)), true)

Definition at line 64 of file zip_crypto_gnutls.h.

◆ _zip_crypto_hmac_t

#define _zip_crypto_hmac_t   gnutls_hmac_hd_t

Definition at line 55 of file zip_crypto_gnutls.h.

◆ _zip_crypto_pbkdf2

#define _zip_crypto_pbkdf2 (   key,
  key_length,
  salt,
  salt_length,
  iterations,
  output,
  output_length 
)    (pbkdf2_hmac_sha1((key_length), (key), (iterations), (salt_length), (salt), (output_length), (output)), true)

Definition at line 66 of file zip_crypto_gnutls.h.

◆ HAVE_SECURE_RANDOM

#define HAVE_SECURE_RANDOM

Definition at line 37 of file zip_crypto_gnutls.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