Sha256: ba552506e5777c1c475c8fd48ca5a769ad44b3ac6c153c51eddcd042730c952f

Contents?: true

Size: 882 Bytes

Versions: 3

Compression:

Stored size: 882 Bytes

Contents

#include <stdio.h>
#include <stdlib.h>
#include "crypto_onetimeauth_poly1305.h"
#include "randombytes.h"

unsigned char key[32];
unsigned char c[10000];
unsigned char a[16];

main()
{
  int clen;
  int i;
  for (clen = 0;clen < 10000;++clen) {
    randombytes(key,sizeof key);
    randombytes(c,clen);
    crypto_onetimeauth_poly1305(a,c,clen,key);
    if (crypto_onetimeauth_poly1305_verify(a,c,clen,key) != 0) {
      printf("fail %d\n",clen);
      return 100;
    }
    if (clen > 0) {
      c[random() % clen] += 1 + (random() % 255);
      if (crypto_onetimeauth_poly1305_verify(a,c,clen,key) == 0) {
        printf("forgery %d\n",clen);
        return 100;
      }
      a[random() % sizeof a] += 1 + (random() % 255);
      if (crypto_onetimeauth_poly1305_verify(a,c,clen,key) == 0) {
        printf("forgery %d\n",clen);
        return 100;
      }
    }
  }
  return 0;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_nacl-0.1.2 ext/ruby_nacl/NaCl/tests/onetimeauth7.c
ruby_nacl-0.1.1 ext/ruby_nacl/NaCl/tests/onetimeauth7.c
ruby_nacl-0.1.0 ext/ruby_nacl/NaCl/tests/onetimeauth7.c