Since I don't really understand the overall issue I am having, it's become very difficult to debug.
char *o_key_pad = (char*)malloc(SHA256_DIGEST_LENGTH*sizeof(char));
for(int i = 0; i < SHA256_DIGEST_LENGTH; i++){
o_key_pad[i] = 'a';
}
printf("%s\n", o_key_pad);
char *i_key_pad = (char*)malloc(SHA256_DIGEST_LENGTH*sizeof(char));
for(int i = 0; i < SHA256_DIGEST_LENGTH; i++){
i_key_pad[i] = 'b';
}
printf("%s\n", o_key_pad);
printf("%s\n", i_key_pad);
And i obtain outputs:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Why does the array 'o_key_pad' get extended to include whatever i put in array 'i_key_pad', seems like some sort of memory issue?
Note: I understand that it can be done more effectively but to show my point more clearly I have laid it out like this.