Begin OpenSSL AES Key transformation
This commit is contained in:
parent
c47fa050fe
commit
77366d9736
2 changed files with 87 additions and 5 deletions
|
@ -45,17 +45,59 @@
|
|||
#include "mod0keecrack.h"
|
||||
|
||||
|
||||
int aes_transformkey(m0_kdbx_header_entry_t *hdr, uint8_t *tkey, size_t tkeylen) {
|
||||
int aes_transformkey(m0_kdbx_header_entry_t *hdr, uint8_t *tkey, size_t tkeylen)
|
||||
{
|
||||
uint64_t rounds = 0;
|
||||
|
||||
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
|
||||
|
||||
EVP_EncryptInit_ex(
|
||||
ctx,
|
||||
EVP_aes_128_ecb(),
|
||||
NULL,
|
||||
key,
|
||||
NULL);
|
||||
|
||||
EVP_EncryptUpdate(
|
||||
ctx,
|
||||
NULL,
|
||||
0,
|
||||
tkey,
|
||||
tkeylen);
|
||||
|
||||
|
||||
for(rounds = 0; rounds < hdr[TRANSFORMROUNDS].qw; rounds++) {
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (ctx) {
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
int aes_decrypt_check(m0_kdbx_header_entry_t *hdr, uint8_t *masterkey, m0_kdbx_payload_t *p) {
|
||||
bool aes_decrypt_check(m0_kdbx_header_entry_t *hdr, uint8_t *masterkey, m0_kdbx_payload_t *p) {
|
||||
|
||||
}
|
||||
|
||||
int sha256_hash(uint8_t *hash, uint8_t *data, size_t len) {
|
||||
EVP_MD_CTX *ctx = EVP_MD_CTX_new();
|
||||
EVP_DigestInit(ctx, EVP_sha256());
|
||||
EVP_DigestUpdate(ctx, data, len);
|
||||
EVP_DigestFinal(ctx, hash, NULL);
|
||||
|
||||
EVP_DigestInit(
|
||||
ctx,
|
||||
EVP_sha256()
|
||||
);
|
||||
|
||||
EVP_DigestUpdate(
|
||||
ctx,
|
||||
data,
|
||||
len
|
||||
);
|
||||
|
||||
EVP_DigestFinal(
|
||||
ctx,
|
||||
hash,
|
||||
NULL
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
40
sha256.c
Normal file
40
sha256.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* =====================================================================================
|
||||
*
|
||||
* Filename: sha256.c
|
||||
*
|
||||
* Description: An OpenSSL SHA256 Utility
|
||||
*
|
||||
* Version: 1.0
|
||||
* Created: 04/03/2018 06:13:41 PM
|
||||
* Revision: none
|
||||
* Compiler: gcc
|
||||
*
|
||||
* Author: William Brawner (Billy), billybrawner@gmail.com
|
||||
* Organization:
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
#include <openssl/evp.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "helper.h"
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
if (argc < 2) {
|
||||
printf("Please enter a string to hash\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("You entered %s\n", argv[1]);
|
||||
printf("Your string contains %d characters\n", strlen(argv[1]));
|
||||
|
||||
EVP_MD_CTX *ctx = EVP_MD_CTX_new();
|
||||
EVP_DigestInit(ctx, EVP_sha256());
|
||||
EVP_DigestUpdate(ctx, argv[1], strlen(argv[1]));
|
||||
char* hash = malloc(EVP_MD_CTX_size(ctx));
|
||||
EVP_DigestFinal(ctx, hash, NULL);
|
||||
printf("Your hashed string: ");
|
||||
print_hex_buf(hash, 32);
|
||||
printf("\n");
|
||||
}
|
Loading…
Reference in a new issue