Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example usage creates buffer overflow #4

Open
lseekio opened this issue Jul 7, 2018 · 1 comment
Open

Example usage creates buffer overflow #4

lseekio opened this issue Jul 7, 2018 · 1 comment

Comments

@lseekio
Copy link

lseekio commented Jul 7, 2018

Example Usage: Output overflows buffer to stdin causing getchar() to close the console immediately after execution.

	uint8_t in[8] = {0x58, 0x7c, 0xb3, 0x98, 0xfe, 0x82, 0xff, 0xda};
	uint8_t out[32];

	shake256(out,256,in,sizeof(in));
	printArray(out,32);
	getchar();

Output should be in bytes not bits. also noted by warmist .
Example where console windows remains open as it should

	uint8_t in[8] = {0x58, 0x7c, 0xb3, 0x98, 0xfe, 0x82, 0xff, 0xda};
	uint8_t out[32];

	shake256(out,32,in,sizeof(in));
	printArray(out,32);
	getchar();
@jweinraub
Copy link

I was getting bad results with sizeof(in) and changed it to strlen instead

Just for sake of completion I'll pate my code program.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "keccak-tiny.h"

int main()
{
   uint8_t *in = "The quick brown fox jumps over the lazy dog";
   uint8_t out[64];
   int      i;
   len = strlen(in);
   shake256(out, 64, in, strlen(in));

   printf("\nThe SHAKE-256 hash of '%s' is:\n", in);
   for ( i = 0; i < 64; i++ )
   {
      printf("%02x", out[i]);
   }

   printf("\n");

   return 0;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants