-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 97eed36
Showing
244 changed files
with
50,923 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
crypto_verify :_BYTES (const unsigned char *,const unsigned char *) | ||
crypto_core :_OUTPUTBYTES:_INPUTBYTES:_KEYBYTES:_CONSTBYTES (unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *) | ||
crypto_hashblocks :_STATEBYTES:_BLOCKBYTES (unsigned char *,const unsigned char *,unsigned long long) | ||
crypto_hash :_BYTES (unsigned char *,const unsigned char *,unsigned long long) | ||
crypto_stream :_xor:_KEYBYTES:_NONCEBYTES (unsigned char *,unsigned long long,const unsigned char *,const unsigned char *):_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *) | ||
crypto_onetimeauth :_verify:_BYTES:_KEYBYTES (unsigned char *,const unsigned char *,unsigned long long,const unsigned char *):_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *) | ||
crypto_auth :_verify:_BYTES:_KEYBYTES (unsigned char *,const unsigned char *,unsigned long long,const unsigned char *):_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *) | ||
crypto_secretbox :_open:_KEYBYTES:_NONCEBYTES:_ZEROBYTES:_BOXZEROBYTES (unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *):_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *) | ||
crypto_scalarmult :_base:_BYTES:_SCALARBYTES (unsigned char *,const unsigned char *,const unsigned char *):_base(unsigned char *,const unsigned char *) | ||
crypto_box :_open:_keypair:_beforenm:_afternm:_open_afternm:_PUBLICKEYBYTES:_SECRETKEYBYTES:_BEFORENMBYTES:_NONCEBYTES:_ZEROBYTES:_BOXZEROBYTES (unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *):_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *):_keypair(unsigned char *,unsigned char *):_beforenm(unsigned char *,const unsigned char *,const unsigned char *):_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *):_open_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
A mirror of Daniel Bernstein (djb) and Tanja Lange's "NaCl: Networking and Cryptography library", | ||
tagged for each release. The main distribution is bereft of public repository or even a changelog; | ||
this is kept for version sanity. | ||
|
||
main site: http://nacl.cr.yp.to/ | ||
|
||
Release: 20090405 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
commandline/nacl-sha256.c version 20080713 | ||
D. J. Bernstein | ||
Public domain. | ||
*/ | ||
|
||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <sys/mman.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include "crypto_hash_sha256.h" | ||
|
||
unsigned char *input; | ||
unsigned long long inputalloc; | ||
unsigned long long inputlen; | ||
|
||
unsigned char h[crypto_hash_sha256_BYTES]; | ||
|
||
void h_print(void) | ||
{ | ||
int i; | ||
for (i = 0;i < crypto_hash_sha256_BYTES;++i) printf("%02x",255 & (int) h[i]); | ||
printf("\n"); | ||
} | ||
|
||
int main() | ||
{ | ||
struct stat st; | ||
int ch; | ||
|
||
if (fstat(0,&st) == 0) { | ||
input = mmap(0,st.st_size,PROT_READ,MAP_SHARED,0,0); | ||
if (input != MAP_FAILED) { | ||
crypto_hash_sha256(h,input,st.st_size); | ||
h_print(); | ||
return 0; | ||
} | ||
} | ||
|
||
input = 0; | ||
inputalloc = 0; | ||
inputlen = 0; | ||
|
||
while ((ch = getchar()) != EOF) { | ||
if (inputlen >= inputalloc) { | ||
void *newinput; | ||
while (inputlen >= inputalloc) | ||
inputalloc = inputalloc * 2 + 1; | ||
if (posix_memalign(&newinput,16,inputalloc) != 0) return 111; | ||
memcpy(newinput,input,inputlen); | ||
free(input); | ||
input = newinput; | ||
} | ||
input[inputlen++] = ch; | ||
} | ||
|
||
crypto_hash_sha256(h,input,inputlen); | ||
h_print(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
commandline/nacl-sha512.c version 20080713 | ||
D. J. Bernstein | ||
Public domain. | ||
*/ | ||
|
||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <sys/mman.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include "crypto_hash_sha512.h" | ||
|
||
unsigned char *input; | ||
unsigned long long inputalloc; | ||
unsigned long long inputlen; | ||
|
||
unsigned char h[crypto_hash_sha512_BYTES]; | ||
|
||
void h_print(void) | ||
{ | ||
int i; | ||
for (i = 0;i < crypto_hash_sha512_BYTES;++i) printf("%02x",255 & (int) h[i]); | ||
printf("\n"); | ||
} | ||
|
||
int main() | ||
{ | ||
struct stat st; | ||
int ch; | ||
|
||
if (fstat(0,&st) == 0) { | ||
input = mmap(0,st.st_size,PROT_READ,MAP_SHARED,0,0); | ||
if (input != MAP_FAILED) { | ||
crypto_hash_sha512(h,input,st.st_size); | ||
h_print(); | ||
return 0; | ||
} | ||
} | ||
|
||
input = 0; | ||
inputalloc = 0; | ||
inputlen = 0; | ||
|
||
while ((ch = getchar()) != EOF) { | ||
if (inputlen >= inputalloc) { | ||
void *newinput; | ||
while (inputlen >= inputalloc) | ||
inputalloc = inputalloc * 2 + 1; | ||
if (posix_memalign(&newinput,16,inputalloc) != 0) return 111; | ||
memcpy(newinput,input,inputlen); | ||
free(input); | ||
input = newinput; | ||
} | ||
input[inputlen++] = ch; | ||
} | ||
|
||
crypto_hash_sha512(h,input,inputlen); | ||
h_print(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
cpucycles/alpha.c version 20060316 | ||
D. J. Bernstein | ||
Public domain. | ||
*/ | ||
|
||
#include <time.h> | ||
#include <unistd.h> | ||
#include <sys/time.h> | ||
|
||
static long long tod(void) | ||
{ | ||
struct timeval t; | ||
gettimeofday(&t,(struct timezone *) 0); | ||
return t.tv_sec * (long long) 1000000 + t.tv_usec; | ||
} | ||
|
||
static long long rpcc(void) | ||
{ | ||
unsigned long long t; | ||
asm volatile("rpcc %0" : "=r"(t)); | ||
return t & 0xffffffff; | ||
} | ||
|
||
static long long firstrpcc; | ||
static long long firsttod; | ||
static long long lastrpcc; | ||
static long long lasttod; | ||
static double mhz = 0; | ||
|
||
static void init(void) | ||
{ | ||
firstrpcc = rpcc(); | ||
firsttod = tod(); | ||
|
||
do { | ||
lastrpcc = rpcc(); | ||
lasttod = tod(); | ||
} while (lasttod - firsttod < 10000); | ||
|
||
lastrpcc -= firstrpcc; lastrpcc &= 0xffffffff; | ||
lasttod -= firsttod; | ||
|
||
mhz = (double) lastrpcc / (double) lasttod; | ||
} | ||
|
||
long long cpucycles_alpha(void) | ||
{ | ||
double x; | ||
long long y; | ||
|
||
if (!mhz) init(); | ||
|
||
lastrpcc = rpcc(); | ||
lasttod = tod(); | ||
|
||
lastrpcc -= firstrpcc; lastrpcc &= 0xffffffff; | ||
lasttod -= firsttod; | ||
|
||
/* Number of cycles since firstrpcc is lastrpcc + 2^32 y for unknown y. */ | ||
/* Number of microseconds since firsttod is lasttod. */ | ||
|
||
x = (lasttod * mhz - lastrpcc) * 0.00000000023283064365386962890625; | ||
y = x; | ||
while (x > y + 0.5) y += 1; | ||
while (x < y - 0.5) y -= 1; | ||
|
||
y *= 4294967296ULL; | ||
lastrpcc += y; | ||
|
||
mhz = (double) lastrpcc / (double) lasttod; | ||
|
||
return firstrpcc + lastrpcc; | ||
} | ||
|
||
long long cpucycles_alpha_persecond(void) | ||
{ | ||
if (!mhz) init(); | ||
return 1000000.0 * mhz; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
cpucycles alpha.h version 20060318 | ||
D. J. Bernstein | ||
Public domain. | ||
*/ | ||
|
||
#ifndef CPUCYCLES_alpha_h | ||
#define CPUCYCLES_alpha_h | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
extern long long cpucycles_alpha(void); | ||
extern long long cpucycles_alpha_persecond(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#ifndef cpucycles_implementation | ||
#define cpucycles_implementation "alpha" | ||
#define cpucycles cpucycles_alpha | ||
#define cpucycles_persecond cpucycles_alpha_persecond | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
|
||
long long cpucycles_amd64cpuinfo(void) | ||
{ | ||
unsigned long long result; | ||
asm volatile(".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax" | ||
: "=a" (result) :: "%rdx"); | ||
return result; | ||
} | ||
|
||
long long cpucycles_amd64cpuinfo_persecond(void) | ||
{ | ||
FILE *f; | ||
double result; | ||
int s; | ||
|
||
f = fopen("/proc/cpuinfo","r"); | ||
if (!f) return 0; | ||
|
||
for (;;) { | ||
s = fscanf(f,"cpu MHz : %lf",&result); | ||
if (s > 0) break; | ||
if (s == 0) s = fscanf(f,"%*[^\n]\n"); | ||
if (s < 0) { result = 0; break; } | ||
} | ||
|
||
fclose(f); | ||
return 1000000.0 * result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
cpucycles amd64cpuinfo.h version 20060318 | ||
D. J. Bernstein | ||
Public domain. | ||
*/ | ||
|
||
#ifndef CPUCYCLES_amd64cpuinfo_h | ||
#define CPUCYCLES_amd64cpuinfo_h | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
extern long long cpucycles_amd64cpuinfo(void); | ||
extern long long cpucycles_amd64cpuinfo_persecond(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#ifndef cpucycles_implementation | ||
#define cpucycles_implementation "amd64cpuinfo" | ||
#define cpucycles cpucycles_amd64cpuinfo | ||
#define cpucycles_persecond cpucycles_amd64cpuinfo_persecond | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
|
||
long long cpucycles_amd64tscfreq(void) | ||
{ | ||
unsigned long long result; | ||
asm volatile(".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax" | ||
: "=a" (result) :: "%rdx"); | ||
return result; | ||
} | ||
|
||
long long cpucycles_amd64tscfreq_persecond(void) | ||
{ | ||
long result = 0; | ||
size_t resultlen = sizeof(long); | ||
sysctlbyname("machdep.tsc_freq",&result,&resultlen,0,0); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
cpucycles amd64tscfreq.h version 20060318 | ||
D. J. Bernstein | ||
Public domain. | ||
*/ | ||
|
||
#ifndef CPUCYCLES_amd64tscfreq_h | ||
#define CPUCYCLES_amd64tscfreq_h | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
extern long long cpucycles_amd64tscfreq(void); | ||
extern long long cpucycles_amd64tscfreq_persecond(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#ifndef cpucycles_implementation | ||
#define cpucycles_implementation "amd64tscfreq" | ||
#define cpucycles cpucycles_amd64tscfreq | ||
#define cpucycles_persecond cpucycles_amd64tscfreq_persecond | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.