int main(int argc, char **argv) { uchar sk1[SECRETKEY_BYTES]; uchar sk2[SECRETKEY_BYTES]; uchar pk1[PUBLICKEY_BYTES]; uchar pk2[PUBLICKEY_BYTES]; ullong sklen1, sklen2, pklen1, pklen2; uchar key1[SHAREDSECRET_BYTES]; uchar key2[SHAREDSECRET_BYTES]; ullong klen1, klen2; keypair(sk1, &sklen1, pk1, &pklen1); keypair(sk2, &sklen2, pk2, &pklen2); printf("\n"); sharedsecret(key1, &klen1, sk1, sklen1, pk2, pklen2); sharedsecret(key2, &klen2, sk2, sklen2, pk1, pklen1); assert(klen1 == klen2); assert(memcmp(key1, key2, klen1) == 0); return 0; }
int main(int argc, char ** argv) { unsigned char sk[SECRETKEY_BYTES], pk[PUBLICKEY_BYTES]; FILE * fichier; char filename[16]; unsigned r; int n; unsigned long long tmp, total; r = (argc > 1) ? atoi(argv[1]) : (((unsigned) rdtsc()) & 0x7fffffff); n = (argc > 2) ? atoi(argv[2]) : 0; if (n == 0) { srandom(r); keypair(sk, pk); sprintf(filename, "pk%d", r); fichier = fopen(filename, "w"); n = EXT_DEGREE; fwrite(&n, sizeof(int), 1, fichier); n = NB_ERRORS; fwrite(&n, sizeof(int), 1, fichier); fwrite(pk, 1, PUBLICKEY_BYTES, fichier); fclose(fichier); sprintf(filename, "sk%d", r); fichier = fopen(filename, "w"); n = EXT_DEGREE; fwrite(&n, sizeof(int), 1, fichier); n = NB_ERRORS; fwrite(&n, sizeof(int), 1, fichier); fwrite(sk, 1, SECRETKEY_BYTES, fichier); fclose(fichier); } else { total = 0; while (n > 0) { srandom(r); tmp = rdtsc(); keypair(sk, pk); tmp = rdtsc() - tmp; total += tmp; --n; ++r; } fichier = fopen("plotkgendata", "a"); fprintf(fichier, "%d\t %d\t %lld\n", LOG_LENGTH, ERROR_WEIGHT, total / atoi(argv[2])); } return 0; }
int main(int argc,char **argv) { if(argc != 2) { fprintf(stderr,"%s [prime|pqg]\n",argv[0]); exit(1); } if(!FIPS_mode_set(1,argv[0])) { ERR_load_crypto_strings(); ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE)); exit(1); } if(!strcmp(argv[1],"prime")) primes(); else if(!strcmp(argv[1],"pqg")) pqg(); else if(!strcmp(argv[1],"keypair")) keypair(); else if(!strcmp(argv[1],"siggen")) siggen(); else if(!strcmp(argv[1],"sigver")) sigver(); else { fprintf(stderr,"Don't know how to %s.\n",argv[1]); exit(1); } return 0; }
int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "%s [prime|pqg|pqgver|keypair|siggen|sigver]\n", argv[0]); exit(1); } if (!FIPS_mode_set(1)) { do_print_errors(); exit(1); } if (!strcmp(argv[1], "prime")) primes(); else if (!strcmp(argv[1], "pqg")) pqg(); else if (!strcmp(argv[1], "pqgver")) pqgver(); else if (!strcmp(argv[1], "keypair")) keypair(); else if (!strcmp(argv[1], "keyver")) keyver(); else if (!strcmp(argv[1], "siggen")) siggen(); else if (!strcmp(argv[1], "sigver")) sigver(); else { fprintf(stderr, "Don't know how to %s.\n", argv[1]); exit(1); } return 0; }
int main(int argc, char **argv) #endif { FILE *in, *out; if (argc == 4) { in = fopen(argv[2], "r"); if (!in) { fprintf(stderr, "Error opening input file\n"); exit(1); } out = fopen(argv[3], "w"); if (!out) { fprintf(stderr, "Error opening output file\n"); exit(1); } } else if (argc == 2) { in = stdin; out = stdout; } else { fprintf(stderr,"%s [prime|pqg|pqgver|keypair|keyver|siggen|sigver]\n",argv[0]); exit(1); } fips_algtest_init(); if(!strcmp(argv[1],"prime")) primes(in, out); else if(!strcmp(argv[1],"pqg")) pqg(in, out); else if(!strcmp(argv[1],"pqgver")) pqgver(in, out); else if(!strcmp(argv[1],"keypair")) keypair(in, out); else if(!strcmp(argv[1],"keyver")) keyver(in, out); else if(!strcmp(argv[1],"siggen")) siggen(in, out); else if(!strcmp(argv[1],"sigver")) sigver(in, out); else { fprintf(stderr,"Don't know how to %s.\n",argv[1]); exit(1); } if (argc == 4) { fclose(in); fclose(out); } return 0; }
int main(int argc, char* arv[]) { unsigned long long sklen = SECRETKEY_BYTES; unsigned long long pklen = PUBLICKEY_BYTES; unsigned long long smlen = SIGNATURE_BYTES; unsigned long long mlen = SHORTMESSAGE_BYTES; unsigned char sk[sklen]; unsigned char pk[pklen]; unsigned char sm[smlen]; unsigned char m[mlen]; int i; unsigned long long int start, stop; init_all(); clear_all(); // Initialise message with random bytes: randombytes(m,SHORTMESSAGE_BYTES); start = cpucycles(); // Generate first key pair: keypair(sk, &sklen, pk, &pklen); stop = cpucycles(); printf("Cycles needed for keypair: %lld\n", stop - start); start = cpucycles(); signedshortmessage(sm, &smlen, m, mlen, sk, sklen); stop = cpucycles(); printf("Cycles needed for signedshortmessage: %lld\n", stop - start); start = cpucycles(); shortmessagesigned(m, &mlen, sm, smlen, pk, pklen); stop = cpucycles(); printf("Cycles needed for shortmessagesigned: %lld\n", stop - start); return 0; }
int main() { srand(time(0)); uint8 c[SIGNATURE_BYTES]; uint8 m[SHORTHASH_BYTES]; uint8 pk[PUBLICKEY_BYTES]; uint8 sk[SECRETKEY_BYTES]; uint64 lc,lm = SHORTHASH_BYTES,lpk,lsk; keypair( sk , &lsk , pk , &lpk ); for( int i=0;i<SHORTHASH_BYTES;i++) m[i] = rand() % 256; for( int i=0;i<SHORTHASH_BYTES;i++) printf("%x " , (unsigned) m[i]); printf("\n"); signatureofshorthash( c , &lc , m , lm , sk , lsk ); for( int i=0;i<SIGNATURE_BYTES;i++) printf("%x " , (unsigned) c[i]); printf("\n"); int i = verification( m , lm , c , lc , pk , lpk ); printf("verify: %d\n" , i ); }
#ifdef _KERNEL #define iswhite(c) ((c == ' ') || (c == '\t')) /* check for white space */ #else /* get it from the headers */ #include <ctype.h> #define iswhite isspace /* use the ctype macro */ #endif /* enum keyword is defined in vinumvar.h */ #define keypair(x) { #x, kw_##x } /* create pair "foo", kw_foo */ #define flagkeypair(x) { "-"#x, kw_##x } /* create pair "-foo", kw_foo */ #define KEYWORDSET(x) {sizeof (x) / sizeof (struct _keywords), x} /* Normal keywords. These are all the words that vinum knows. */ struct _keywords keywords[] = {keypair(drive), keypair(sd), keypair(subdisk), keypair(plex), keypair(volume), keypair(vol), keypair(setupstate), keypair(readpol), keypair(org), keypair(name), keypair(writethrough), keypair(writeback), keypair(raw), keypair(device), keypair(concat), keypair(raid5),