Parcourir la source

DEV WIP

master
Krzysztof Kwiatkowski il y a 8 ans
Parent
révision
dfce6a02b6
6 fichiers modifiés avec 164 ajouts et 212 suppressions
  1. +41
    -4
      prj/Matasano.sublime-project
  2. +86
    -196
      prj/Matasano.sublime-workspace
  3. +23
    -3
      sol/set2.c
  4. +10
    -7
      sol/set2.h
  5. +1
    -1
      src/base64.cpp
  6. +3
    -1
      src/base64.h

+ 41
- 4
prj/Matasano.sublime-project Voir le fichier

@@ -2,13 +2,50 @@
"folders":
[
{
"path": "/home/flowher/repos/MatasanoCrypto"
},
{
"file_exclude_patterns":
[
"# Object files",
"*.o",
"*.ko",
"*.obj",
"*.elf",
"# Precompiled Headers",
"*.gch",
"*.pch",
"# Libraries",
"*.lib",
"*.a",
"*.la",
"*.lo",
"# Shared objects (inc. Windows DLLs)",
"*.dll",
"*.so",
"*.so.*",
"*.dylib",
"# Executables",
"*.exe",
"*.out",
"*.app",
"*.i*86",
"*.x86_64",
"*.hex",
"# Debug files",
"*.dSYM/"
],
"folder_exclude_patterns":
[
""
],
"path": "/home/flowher/repos/OpenCrypto"
},
{
"path": "/home/flowher/repos/notes/french/words"
},
{
"path": "/home/flowher/repos/notes"
},
{
"path": "/home/flowher/repos/MatasanoCrypto"
}
],
]
}

+ 86
- 196
prj/Matasano.sublime-workspace
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 23
- 3
sol/set2.c Voir le fichier

@@ -1,6 +1,7 @@
#include "src/common.h"
#include "src/pkcs7.h"
#include "src/enc_modes.h"
#include "src/base64.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -76,7 +77,7 @@ TCASE(ecb_encrypt_decrypt_single_block)
}
TCASE_E

TCASE(pkcs7_test)
TCASE(set2_challange9)
{
const uint8_t text1[] = "Text1";
uint8_t unpadded[32] = {0};
@@ -103,7 +104,7 @@ TCASE(pkcs7_test)
}
TCASE_E

TCASE(cbc_decrypt_test)
TCASE(set2_challange10)
{
static const uint8_t expected_result[34] = "I'm back and I'm ringin' the bell";
CryptoAttribs_t attribs;
@@ -370,7 +371,7 @@ Result_t encryption_oracle( const uint8_t* pt,
return ret;
}

TCASE(encode_oracle_test)
TCASE(set2_challange11)
{
// let's run it 1000 times
for(size_t i=0; i<1000; ++i)
@@ -459,5 +460,24 @@ TCASE(encrypt_padding_pkcs7)
::free(attribs_dec.output);
}
::free(attribs_enc.output);
}
TCASE_E

TCASE(set2_challange12_not_finished)
{
uint8_t CIPHERTEXT[] = "Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkg"
"aGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyBq"
"dXN0IHRvIHNheSBoaQpEaWQgeW91IHN0b3A/IE5vLCBJIGp1c3QgZHJvdmUg"
"YnkK";

uint8_t HEX_STRING[sizeof CIPHERTEXT];
uint8_t CONCAT_STRING[sizeof(CIPHERTEXT)*2];
CryptoAttribs_t EncryptForBS;

Key_t key;
uint32_t hex_len = 0;
hex_len = base64_to_hex(CIPHERTEXT, sizeof(CIPHERTEXT), HEX_STRING);


}
TCASE_E

+ 10
- 7
sol/set2.h Voir le fichier

@@ -3,15 +3,16 @@

#include "src/common.h"


void pkcs7_test();
void cbc_decrypt_test();
void cbc_enc_dec_test();
void ecb_encrypt_decrypt_single_block();
void encode_decode_openssl();
void encode_oracle_test();
void encrypt_padding_pkcs7();

void set2_challange9();
void set2_challange10();
void set2_challange11();
void set2_challange12_not_finished();

struct OpenSSL
{
static Result_t Cbc(CryptoAttribs_t* i_attribs,
@@ -22,13 +23,15 @@ struct SET2
{
static void run()
{
encode_oracle_test();
ecb_encrypt_decrypt_single_block();
pkcs7_test();
encode_decode_openssl();
cbc_decrypt_test();
cbc_enc_dec_test();
encrypt_padding_pkcs7();

set2_challange9();
set2_challange10();
set2_challange11();
set2_challange12_not_finished();
}
};



+ 1
- 1
src/base64.cpp Voir le fichier

@@ -233,7 +233,7 @@ struct int24 base64_4char_to_hex(const char (&T)[4])
-------------------------------------------------------------------------------- */
int base64_to_hex( const unsigned char* const i_string,
int i_string_len,
unsigned char* o_hex_array )
uint8_t* o_hex_array )
{
int pointer = 0;
int hex_pointer = 0;


+ 3
- 1
src/base64.h Voir le fichier

@@ -1,8 +1,10 @@
#ifndef _base64_H_
#define _base64_H_

#include <stdint.h>

unsigned hex_to_base64(const char* hex_buff, char* base64_buff, unsigned hex_buff_len );
int base64_to_hex(const unsigned char* const i_string, int i_string_len, unsigned char* o_hex_array );
int base64_to_hex(const unsigned char* const i_string, int i_string_len, uint8_t* o_hex_array );
void convert_string_to_hex(const char* const iArray, const unsigned iArrayLen, unsigned char* oHexArray);
void convert_hex_to_string(const unsigned char* const iHexArray, unsigned iHexArrayLen, char* oStringBuf );
void xor_strings(const char* const iLeftString, const char* const iRightString, unsigned char* oXorArray);


Chargement…
Annuler
Enregistrer