Rizin
unix-like reverse engineering framework and cli tools
zip_crypto_commoncrypto.c File Reference
#include <stdlib.h>
#include "zipint.h"
#include "zip_crypto.h"
#include <fcntl.h>
#include <unistd.h>

Go to the source code of this file.

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)
 

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

References in, len, out, and ZIP_CRYPTO_AES_BLOCK_LENGTH.

◆ _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

References NULL.

Referenced by _zip_winzip_aes_free(), and _zip_winzip_aes_new().

◆ _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

References error(), key, NULL, ZIP_ER_INTERNAL, ZIP_ER_INVAL, ZIP_ER_MEMORY, and zip_error_set().

Referenced by _zip_winzip_aes_new().

◆ _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

References _zip_crypto_clear, free(), and NULL.

Referenced by _zip_winzip_aes_free().

◆ _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

References error(), malloc(), NULL, ZIP_ER_MEMORY, and zip_error_set().

Referenced by _zip_winzip_aes_new().