2020-12-05 13:08:24 +01:00
|
|
|
#pragma once
|
2014-04-12 11:42:20 +02:00
|
|
|
|
2014-10-01 15:57:44 +02:00
|
|
|
// Copyright (C) 2014 Hykem <hykem@hotmail.com>
|
2021-05-02 10:26:32 +02:00
|
|
|
// Licensed under the terms of the GNU GPL, version 2.0 or later versions.
|
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
2014-10-01 15:57:44 +02:00
|
|
|
|
2020-12-12 13:01:29 +01:00
|
|
|
#include "util/types.hpp"
|
2016-02-01 22:52:27 +01:00
|
|
|
|
2014-10-01 15:57:44 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2025-04-05 21:50:45 +02:00
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
CRYPTO_MAX_PATH = 4096
|
|
|
|
|
};
|
2020-10-10 09:19:49 +02:00
|
|
|
|
|
|
|
|
char* extract_file_name(const char* file_path, char real_file_name[CRYPTO_MAX_PATH]);
|
2014-04-12 11:42:20 +02:00
|
|
|
|
2022-06-06 22:06:42 +02:00
|
|
|
std::string sha256_get_hash(const char* data, usz size, bool lower_case);
|
|
|
|
|
|
2014-04-12 11:42:20 +02:00
|
|
|
// Hex string conversion auxiliary functions.
|
|
|
|
|
u64 hex_to_u64(const char* hex_str);
|
2025-04-05 21:50:45 +02:00
|
|
|
void hex_to_bytes(unsigned char* data, const char* hex_str, unsigned int str_length);
|
2014-03-30 22:09:49 +02:00
|
|
|
|
|
|
|
|
// Crypto functions (AES128-CBC, AES128-ECB, SHA1-HMAC and AES-CMAC).
|
2025-04-05 21:50:45 +02:00
|
|
|
void aescbc128_decrypt(unsigned char* key, unsigned char* iv, unsigned char* in, unsigned char* out, usz len);
|
|
|
|
|
void aescbc128_encrypt(unsigned char* key, unsigned char* iv, unsigned char* in, unsigned char* out, usz len);
|
|
|
|
|
void aesecb128_encrypt(unsigned char* key, unsigned char* in, unsigned char* out);
|
|
|
|
|
bool hmac_hash_compare(unsigned char* key, int key_len, unsigned char* in, usz in_len, unsigned char* hash, usz hash_len);
|
|
|
|
|
void hmac_hash_forge(unsigned char* key, int key_len, unsigned char* in, usz in_len, unsigned char* hash);
|
|
|
|
|
bool cmac_hash_compare(unsigned char* key, int key_len, unsigned char* in, usz in_len, unsigned char* hash, usz hash_len);
|
|
|
|
|
void cmac_hash_forge(unsigned char* key, int key_len, unsigned char* in, usz in_len, unsigned char* hash);
|
|
|
|
|
void mbedtls_zeroize(void* v, size_t n);
|
2021-07-27 11:04:46 +02:00
|
|
|
|
|
|
|
|
// SC passphrase crypto
|
|
|
|
|
|
|
|
|
|
int vtrm_decrypt(int type, u8* iv, u8* input, u8* output);
|
|
|
|
|
int vtrm_decrypt_master(s64 laid, s64 paid, u8* iv, u8* input, u8* output);
|
|
|
|
|
int vtrm_decrypt_with_portability(int type, u8* iv, u8* input, u8* output);
|