Coder Social home page Coder Social logo

waterjuice / wjcryptlib Goto Github PK

View Code? Open in Web Editor NEW
467.0 20.0 174.0 276 KB

Public Domain C Library of Cryptographic functions. Including: MD5, SHA1, SHA256, SHA512, RC4, AES, AES-CTR, AES-OFB, AES-CBC

Home Page: http://waterjuice.org

License: The Unlicense

C 99.12% CMake 0.88%
aes aes-ctr aes-ofb aes-cbc sha1 rc4 md5 sha256 sha512 sha2

wjcryptlib's Introduction

WjCryptLib

WjCryptLib is a collection of cryptographic functions written in C. Each module is fully independent and generally requires only a single .c file and a a single .h file. AES-CTR does depend on the AES module, so in this case all four files are needed.

The functions are designed to be portable and have been tested on both a Little-Endian and a Big-Endian architecture. OpenMP is supported where parallelisation can occur.

The library and the demo programs can be built using CMake to generate a build setup for any system, including Visual Studio on Windows and Make or Ninja for Linux. Refer to cmake.org to get CMake.

Placed into Public Domain by WaterJuice 2013 - 2018

Library

To use the library functions, only the following files are required, depending on what cryptographic functions are wanted.

  • MD5 - (WjCryptLib_Md5.h, and WjCryptLib_Md5.c)
  • SHA1 - (WjCryptLib_Sha1.h, and WjCryptLib_Sha1.c)
  • SHA256 - (WjCryptLib_Sha256.h, and WjCryptLib_Sha256.c)
  • SHA512 - (WjCryptLib_Sha512.h, and WjCryptLib_Sha512.c)
  • RC4 - (WjCryptLib_Rc4.h, and WjCryptLib_Rc4.c)
  • AES - (WjCryptLib_Aes.h, and WjCryptLib_Aes.c)
  • AES-CTR - (WjCryptLib_AesCtr.h, and WjCryptLib_AesCtr.c, WjCryptLib_Aes.h, and WjCryptLib_Aes.c)
  • AES-OFB - (WjCryptLib_AesOfb.h, and WjCryptLib_AesOfb.c, WjCryptLib_Aes.h, and WjCryptLib_Aes.c)
  • AES-CBC - (WjCryptLib_AesCbc.h, and WjCryptLib_AesCbc.c, WjCryptLib_Aes.h, and WjCryptLib_Aes.c)

Version 2.3.0 - March 2018

  • Added AES-CBC module.
  • Added functions Md5Calculate, Sha1Calculate, Sha256Calculate, and Sha512Calculate to calculate a hash in one call.
  • Added function Rc4XorWithKey to encrypt/decrypt a buffer with RC4 in one call.
  • Bugfix: AesInitialise now returns -1 if invalid key size is provided. Previously it would return 0 despite what was documented.

Version 2.2.0 - January 2018

  • Added AES-OFB module.
  • File names have been changed to have the prefix WjCryptLib_ rather than CryptLib_.
  • Removed compiled binaries from source tree.

Version 2.1.0 - December 2017

Changes:

  • Changed implementation of AES to one which is almost 5 times as fast. The new implementation comes from LibTomCrypt. The newer implementation produces a larger binary size as a trade-off.
  • AES-CTR module now supports OpenMP and when compiled with OpenMP will run in parallel giving a much greater speed.
  • Changed interface for Initialisation functions for both AES and AES-CTR to be match RC4 (The context is first parameter not last)

Version 2.0.0 - December 2017

Changes:

  • Added AES and AES-CTR modules. AES-CTR conforms to the same counter mode used with AES in OpenSSL.
  • All algorithms now work on Big-Endian architectures.
  • Now uses CMake for building rather than make files and Visual Studio projects. CMake will generate whatever system is required.
  • Input function parameters are now marked const
  • File names have been changed to have the prefix CryptLib_ rather than Lib.
  • Various formatting changes to the files.

Version 1.0.0 - June 2013

Contains following algorithms:

  • MD5
  • SHA1
  • SHA256
  • SHA512
  • RC4

Test Programs

In the projects directory there are several programs that compile to command line executables. One is WjCryptLibTest. This tests the algorithms against known test vectors. If compiling on a different system this is useful to verify that the results are still valid.

Additionally there are sample programs that demonstrate the functions. For each of the hash functions there is a program that creates a hash from a string given on command line. For RC4 and AES-CTR there are programs that output the stream in hex.

  • Md5String
  • Sha1String
  • Sha256String
  • Sha512String
  • Rc4Output
  • AesBlock
  • AesCtrOutput
  • AesOfbOutput

Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

wjcryptlib's People

Contributors

pjstadig avatar waterjuice avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wjcryptlib's Issues

Why the final result is different?

Hi, I'm using this library in a source code ... The problem is the fact that this package removes zeroes from the final buffer ....

Software:
Input: 000102030405060708090a0b0c0d0e0f
Output from the package (strlen: 124):
fb8563ac7ba46c22244125daa793c1a79d20f9adcbe1cbd5d9d335476cca67e8e76a15a8d7c72c937e24b36a5b5ee45c7d621817f4d5be8c242bd19d5043

Online website:
The real outcome (strlen 128):
source2: https://passwordsgenerator.net/sha512-hash-generator/
FB8563AC7BA46C22244125DAA793C1A79D20F9ADCBE1CBD5D9D335476CCA67E8E76A15A8D7C72C0937E24B036A5B5EE45C7D6218170F04D5BE8C242BD19D5043

There are several "0" eliminated from it ...
Thanks for all your efforts ...

WjCryptLib_Aes.c run error

Firstly: WjCryptLib_Aes.c line 807 "rk -= 3; rrk -= 3;" should be "rk+=3;rrk-=3"
Secondly:when I run the Aes.c Aes.h and Aesblocks,the result is not same

`
C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>untitled.exe -d 31333530373336333235303133353037 b657a40c5f87fb28ca83e5cd745eefc9
c16a6767fdfdc6e94b6b7118a97759ae

C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>untitled.exe -d 31333530373336333235303133353037 b657a40c5f87fb28ca83e5cd745eefc9
109ec21650f21d6f98369528af40ee16

C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>untitled.exe -d 31333530373336333235303133353037 b657a40c5f87fb28ca83e5cd745eefc9
90731999c61709d65c9c02d61349e957

C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>untitled.exe -d 31333530373336333235303133353037 b657a40c5f87fb28ca83e5cd745eefc9
75f50e479ddae51a329ba9da55210159

C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>untitled.exe -d 31333530373336333235303133353037 b657a40c5f87fb28ca83e5cd745eefc9
7965d684ab3ee49697bb7006701fc93c

C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>untitled.exe -d 31333530373336333235303133353037 b657a40c5f87fb28ca83e5cd745eefc9
04d93eec6c290a8694f6afd6e000f43c

C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>untitled.exe -d 31333530373336333235303133353037 b657a40c5f87fb28ca83e5cd745eefc9
c67ef2fdff6ce041956206b15d4c3131

C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>untitled.exe -d 31333530373336333235303133353037 b657a40c5f87fb28ca83e5cd745eefc9
43f0d7fc2011590770913ea69f9d59b1

C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>untitled.exe -d 31333530373336333235303133353037 b657a40c5f87fb28ca83e5cd745eefc9
3c6c56e8d0700cc5b0cbd5f5cc51ec86

C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>untitled.exe -d 31333530373336333235303133353037 b657a40c5f87fb28ca83e5cd745eefc9
892e8664d2d49952e812fe3cb59e6051

C:\Users\tianheguoyun\Desktop\temp\build-untitled-Desktop_Qt_5_6_3_MinGW_32bit-Debug\debug>`

I hope author can take free time to help answer my question。thank you!

Conversion from this to openssl

Hello, no issue there ! the sha512 algo is working very fine but it's to slow.. I just changed to the functions from libopenssl and...the result is not the same.
I'm using it to encode in sha512crypt, and there are twisted procedure like the convertion from the 64bytes digest to a 86 bytes one.
Do you have any idea why in simply switching my program (at https://github.com/e2002e/zhou) to openssl doesn't work ? of course I took in consideration the two main differences, being that SHA512_Final takes the output before the context, and that the ouput is a SHA512_HASH in your library while it's a 64 characters array in your library

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.