-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
80ae84e
commit 2f3ca74
Showing
12 changed files
with
428 additions
and
4 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,83 @@ | ||
Compilation Copyright (c) 1995-2019 by Wei Dai. All rights reserved. | ||
This copyright applies only to this software distribution package | ||
as a compilation, and does not imply a copyright on any particular | ||
file in the package. | ||
|
||
All individual files in this compilation are placed in the public domain by | ||
Wei Dai and other contributors. | ||
|
||
I would like to thank the following authors for placing their works into | ||
the public domain: | ||
|
||
Joan Daemen - 3way.cpp | ||
Leonard Janke - cast.cpp, seal.cpp | ||
Steve Reid - cast.cpp | ||
Phil Karn - des.cpp | ||
Andrew M. Kuchling - md2.cpp, md4.cpp | ||
Colin Plumb - md5.cpp | ||
Seal Woods - rc6.cpp | ||
Chris Morgan - rijndael.cpp | ||
Paulo Baretto - rijndael.cpp, skipjack.cpp, square.cpp | ||
Richard De Moliner - safer.cpp | ||
Matthew Skala - twofish.cpp | ||
Kevin Springle - camellia.cpp, shacal2.cpp, ttmac.cpp, whrlpool.cpp, ripemd.cpp | ||
Ronny Van Keer - sha3.cpp | ||
Aumasson, Neves, Wilcox-O'Hearn and Winnerlein - blake2.cpp, blake2b_simd.cpp, blake2s_simd.cpp | ||
Aaram Yun - aria.cpp, aria_simd.cpp | ||
Han Lulu, Markku-Juhani O. Saarinen - sm4.cpp sm4_simd.cpp | ||
Daniel J. Bernstein, Jack Lloyd - chacha.cpp, chacha_simd.cpp, chacha_avx.cpp | ||
Andrew Moon - ed25519, x25519, donna_32.cpp, donna_64.cpp, donna_sse.cpp | ||
|
||
The Crypto++ Library uses portions of Andy Polyakov's CRYPTOGAMS for Poly1305 | ||
scalar multiplication, aes_armv4.S, sha1_armv4.S and sha256_armv4.S. CRYPTOGAMS | ||
is dual licensed with a permissive BSD-style license. The CRYPTOGAMS license is | ||
reproduced below. | ||
|
||
The Crypto++ Library uses portions of Jack Lloyd's Botan for ChaCha SSE2 and | ||
AVX. Botan placed the code in public domain for Crypto++ to use. | ||
|
||
The Crypto++ Library (as a compilation) is currently licensed under the Boost | ||
Software License 1.0 (http://www.boost.org/users/license.html). | ||
|
||
Boost Software License - Version 1.0 - August 17th, 2003 | ||
|
||
Permission is hereby granted, free of charge, to any person or organization | ||
obtaining a copy of the software and accompanying documentation covered by | ||
this license (the "Software") to use, reproduce, display, distribute, | ||
execute, and transmit the Software, and to prepare derivative works of the | ||
Software, and to permit third-parties to whom the Software is furnished to | ||
do so, all subject to the following: | ||
|
||
The copyright notices in the Software and this entire statement, including | ||
the above license grant, this restriction and the following disclaimer, | ||
must be included in all copies of the Software, in whole or in part, and | ||
all derivative works of the Software, unless such copies or derivative | ||
works are solely in the form of machine-executable object code generated by | ||
a source language processor. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | ||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. | ||
|
||
CRYPTOGAMS License | ||
|
||
Copyright (c) 2006-2017, CRYPTOGAMS by <appro@openssl.org> | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
* Redistributions of source code must retain copyright notices, | ||
this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials | ||
provided with the distribution. | ||
* Neither the name of the CRYPTOGAMS nor the names of its copyright | ||
holder and contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. |
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 @@ | ||
Part of https://github.com/weidai11/cryptopp will be copied here, but I cannot find "the proper part" so far. |
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,47 @@ | ||
#include <stdio.h> | ||
|
||
#include "../zlib/zlib.h" | ||
#include <cryptopp/zdeflate.h> | ||
#include <cryptopp/zinflate.h> | ||
|
||
extern "C" int cryptopp_deflate( | ||
unsigned char *dest, | ||
size_t *destLen, | ||
const unsigned char *source, | ||
size_t sourceLen, | ||
int level | ||
){ | ||
CryptoPP::Deflator zipper(NULL,level,CryptoPP::Deflator::DEFAULT_LOG2_WINDOW_SIZE,false); | ||
//zipper.Put(source,sourceLen); | ||
zipper.Put2(source,sourceLen,1,true); | ||
//zipper.MessageEnd(); // Put2 already sends MessageEnd, so this line will cause double-call (?) | ||
size_t avail = zipper.MaxRetrievable(); | ||
if(!avail)return Z_NEED_DICT; // ??? | ||
if(avail>*destLen)return Z_BUF_ERROR; | ||
*destLen = avail; | ||
zipper.Get(dest,avail); | ||
return 0; | ||
} | ||
|
||
extern "C" int cryptopp_inflate( | ||
unsigned char *dest, | ||
size_t *destLen, | ||
const unsigned char *source, | ||
size_t sourceLen | ||
){ | ||
CryptoPP::Inflator zipper; | ||
try{ | ||
//zipper.Put(source,sourceLen); | ||
zipper.Put2(source,sourceLen,1,true); | ||
//zipper.MessageEnd(); | ||
}catch(CryptoPP::Inflator::BadBlockErr){ | ||
return Z_DATA_ERROR; | ||
}catch(CryptoPP::Inflator::BadDistanceErr){ | ||
return Z_DATA_ERROR; | ||
} | ||
size_t avail = zipper.MaxRetrievable(); | ||
if(avail>*destLen)return Z_BUF_ERROR; | ||
*destLen = avail; | ||
zipper.Get(dest,avail); | ||
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,33 @@ | ||
#include <limits.h> | ||
#include "xorshift.h" | ||
|
||
//I hope (sizeof(val)*CHAR_BIT-(rot)) will be precalculated in compilation. | ||
//#define lrotr(val,rot) (( (val)<<(sizeof(val)*CHAR_BIT-(rot)) )|( (val)>>(rot) )) | ||
#define lrotl(val,rot) (( (val)<<(rot) )|( (val)>>(sizeof(val)*CHAR_BIT-(rot)) )) | ||
|
||
static unsigned int x = 123456789; | ||
static unsigned int y = 362436069; | ||
static unsigned int z = 521288629; | ||
static unsigned int w = 88675123; | ||
|
||
unsigned int xor_rand(){ | ||
unsigned int t; | ||
t=x^(x<<11); | ||
x=y;y=z;z=w; | ||
return w=(w^(w>>19)) ^ (t^(t>>8)); | ||
} | ||
|
||
// http://d.hatena.ne.jp/gintenlabo/20100930/1285859540 | ||
void xor_srand(unsigned int seed){ | ||
#if 1 | ||
x^=seed; | ||
y^=lrotl(seed,17); | ||
z^=lrotl(seed,31); | ||
w^=lrotl(seed,18); | ||
#else | ||
x^=lrotl(seed,14); | ||
y^=lrotl(seed,31); | ||
z^=lrotl(seed,13); | ||
w^=seed; | ||
#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,15 @@ | ||
#ifndef _XORSHIFT_H_ | ||
#define _XORSHIFT_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C"{ | ||
#endif | ||
|
||
unsigned int xor_rand(); | ||
void xor_srand(unsigned int seed); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#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,101 @@ | ||
#include "../compat.h" | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <ctype.h> | ||
#include "xutil.h" | ||
|
||
unsigned long long int read64(const void *p){ | ||
const unsigned char *x=(const unsigned char*)p; | ||
return x[0]|(x[1]<<8)|(x[2]<<16)|((unsigned int)x[3]<<24)|( (unsigned long long int)(x[4]|(x[5]<<8)|(x[6]<<16)|((unsigned int)x[7]<<24)) <<32); | ||
} | ||
|
||
#if 0 | ||
//write32 is now defined in lzmasdk.c. | ||
unsigned int read32(const void *p){ | ||
const unsigned char *x=(const unsigned char*)p; | ||
return x[0]|(x[1]<<8)|(x[2]<<16)|((unsigned int)x[3]<<24); | ||
} | ||
#endif | ||
|
||
unsigned int read24(const void *p){ | ||
const unsigned char *x=(const unsigned char*)p; | ||
return x[0]|(x[1]<<8)|(x[2]<<16); | ||
} | ||
|
||
unsigned short read16(const void *p){ | ||
const unsigned char *x=(const unsigned char*)p; | ||
return x[0]|(x[1]<<8); | ||
} | ||
|
||
void write64(void *p, const unsigned long long int n){ | ||
unsigned char *x=(unsigned char*)p; | ||
x[0]=n&0xff,x[1]=(n>>8)&0xff,x[2]=(n>>16)&0xff,x[3]=(n>>24)&0xff, | ||
x[4]=(n>>32)&0xff,x[5]=(n>>40)&0xff,x[6]=(n>>48)&0xff,x[7]=(n>>56)&0xff; | ||
} | ||
|
||
#if 0 | ||
//write32 is now defined in lzmasdk.c. | ||
void write32(void *p, const unsigned int n){ | ||
unsigned char *x=(unsigned char*)p; | ||
x[0]=n&0xff,x[1]=(n>>8)&0xff,x[2]=(n>>16)&0xff,x[3]=(n>>24)&0xff; | ||
} | ||
#endif | ||
|
||
void write24(void *p, const unsigned int n){ | ||
unsigned char *x=(unsigned char*)p; | ||
x[0]=n&0xff,x[1]=(n>>8)&0xff,x[2]=(n>>16)&0xff; | ||
} | ||
|
||
void write16(void *p, const unsigned short n){ | ||
unsigned char *x=(unsigned char*)p; | ||
x[0]=n&0xff,x[1]=(n>>8)&0xff; | ||
} | ||
|
||
unsigned long long int read64be(const void *p){ | ||
const unsigned char *x=(const unsigned char*)p; | ||
return x[7]|(x[6]<<8)|(x[5]<<16)|((unsigned int)x[4]<<24)|( (unsigned long long int)(x[3]|(x[2]<<8)|(x[1]<<16)|((unsigned int)x[0]<<24)) <<32); | ||
} | ||
|
||
unsigned int read32be(const void *p){ | ||
const unsigned char *x=(const unsigned char*)p; | ||
return x[3]|(x[2]<<8)|(x[1]<<16)|((unsigned int)x[0]<<24); | ||
} | ||
|
||
unsigned int read24be(const void *p){ | ||
const unsigned char *x=(const unsigned char*)p; | ||
return x[2]|(x[1]<<8)|(x[0]<<16); | ||
} | ||
|
||
unsigned short read16be(const void *p){ | ||
const unsigned char *x=(const unsigned char*)p; | ||
return x[1]|(x[0]<<8); | ||
} | ||
|
||
void write64be(void *p, const unsigned long long int n){ | ||
unsigned char *x=(unsigned char*)p; | ||
x[7]=n&0xff,x[6]=(n>>8)&0xff,x[5]=(n>>16)&0xff,x[4]=(n>>24)&0xff, | ||
x[3]=(n>>32)&0xff,x[2]=(n>>40)&0xff,x[1]=(n>>48)&0xff,x[0]=(n>>56)&0xff; | ||
} | ||
|
||
void write32be(void *p, const unsigned int n){ | ||
unsigned char *x=(unsigned char*)p; | ||
x[3]=n&0xff,x[2]=(n>>8)&0xff,x[1]=(n>>16)&0xff,x[0]=(n>>24)&0xff; | ||
} | ||
|
||
void write24be(void *p, const unsigned int n){ | ||
unsigned char *x=(unsigned char*)p; | ||
x[2]=n&0xff,x[1]=(n>>8)&0xff,x[0]=(n>>16)&0xff; | ||
} | ||
|
||
void write16be(void *p, const unsigned short n){ | ||
unsigned char *x=(unsigned char*)p; | ||
x[1]=n&0xff,x[0]=(n>>8)&0xff; | ||
} | ||
|
||
char* myfgets(char *buf,int n,FILE *fp){ //accepts LF/CRLF | ||
char *ret=fgets(buf,n,fp); | ||
if(!ret)return NULL; | ||
if(strlen(buf)&&buf[strlen(buf)-1]=='\n')buf[strlen(buf)-1]=0; | ||
if(strlen(buf)&&buf[strlen(buf)-1]=='\r')buf[strlen(buf)-1]=0; | ||
return ret; | ||
} |
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,68 @@ | ||
#ifndef _XUTIL_H_ | ||
#define _XUTIL_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C"{ | ||
#endif | ||
|
||
#include <stdio.h> | ||
#include <stdbool.h> | ||
|
||
unsigned long long read64(const void *p); | ||
unsigned int read32(const void *p); | ||
unsigned int read24(const void *p); | ||
unsigned short read16(const void *p); | ||
|
||
void write64(void *p, const unsigned long long n); | ||
void write32(void *p, const unsigned int n); | ||
void write24(void *p, const unsigned int n); | ||
void write16(void *p, const unsigned short n); | ||
|
||
unsigned long long read64be(const void *p); | ||
unsigned int read32be(const void *p); | ||
unsigned int read24be(const void *p); | ||
unsigned short read16be(const void *p); | ||
|
||
void write64be(void *p, const unsigned long long n); | ||
void write32be(void *p, const unsigned int n); | ||
void write24be(void *p, const unsigned int n); | ||
void write16be(void *p, const unsigned short n); | ||
|
||
//accepts LF/CRLF | ||
char* myfgets(char *buf,int n,FILE *fp); | ||
|
||
void msleep(int msec); | ||
int strchrindex(const char *s, const int c, const int idx); | ||
unsigned int txt2bin(const char *src, unsigned char *dst, unsigned int len); | ||
|
||
size_t _FAT_directory_mbstoucs2(unsigned short* dst, const unsigned char* src, size_t len); | ||
size_t mbstoucs2(unsigned short* dst, const unsigned char* src); | ||
size_t _FAT_directory_ucs2tombs(unsigned char* dst, const unsigned short* src, size_t len); | ||
size_t ucs2tombs(unsigned char* dst, const unsigned short* src); | ||
|
||
void NullMemory(void* buf, unsigned int n); | ||
int memcmp_fast(const void *x,const void *y,unsigned int n); | ||
|
||
void *_memmem(const void *s1, size_t siz1, const void *s2, size_t siz2); | ||
void *_memstr(const void *s1, const char *s2, size_t siz1); | ||
|
||
int makedir(const char *_dir); | ||
bool wildmatch(const char *pattern, const char *compare); | ||
|
||
enum{ | ||
wildmode_string, | ||
wildmode_samedir, | ||
wildmode_recursive, | ||
}; | ||
|
||
bool matchwildcard(const char *wildcard, const char *string); | ||
bool matchwildcard2(const char *wildcard, const char *string, const int iMode); | ||
|
||
bool fixpath(const char *src, char *dest); | ||
const char* mybasename(const char *src); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#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
Oops, something went wrong.