Browse Source

update readme

Ugochukwu Mmaduekwe 6 years ago
parent
commit
960b85e864
3 changed files with 157 additions and 119 deletions
  1. 4 4
      CryptoLib/src/Include/CryptoLib.inc
  2. 14 8
      CryptoLib/src/Utils/Randoms/ClpOSRandom.pas
  3. 139 107
      README.md

+ 4 - 4
CryptoLib/src/Include/CryptoLib.inc

@@ -19,8 +19,8 @@
 
 (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
 {$IFDEF FPC}
-   {$I CryptoLibHelper.inc} // Had to Include this Since Delphi Does not allow "FPC_FULLVERSION" to Compile.
-   {$UNDEF DELPHI}
+{$I CryptoLibHelper.inc} // Had to Include this Since Delphi Does not allow "FPC_FULLVERSION" to Compile.
+{$UNDEF DELPHI}
 {$MODE delphi}
 
 {$IFDEF CPU386}
@@ -55,8 +55,8 @@
          {$ELSE}
             {$DEFINE CRYPTOLIB_MACOSX}
          {$IFEND}
-      {$ELSEIF DEFINED(FREEBSD) OR DEFINED(NETBSD) OR DEFINED(OPENBSD)}
-         {$DEFINE CRYPTOLIB_TRUEBSD}
+      {$ELSEIF DEFINED(FREEBSD) OR DEFINED(NETBSD) OR DEFINED(OPENBSD) OR DEFINED(DRAGONFLY)}
+         {$DEFINE CRYPTOLIB_GENERIC_BSD}
       {$IFEND}
   {$ELSEIF DEFINED(LINUX)}
      {$DEFINE CRYPTOLIB_LINUX}

+ 14 - 8
CryptoLib/src/Utils/Randoms/ClpOSRandom.pas

@@ -71,7 +71,7 @@ resourcestring
   SLinuxGetRandomError =
     'An Error Occured while generating random data using getRandom API';
 {$ENDIF}
-{$IFDEF CRYPTOLIB_TRUEBSD}
+{$IFDEF CRYPTOLIB_GENERIC_BSD}
   SArc4RandomBufGenerationError =
     'An Error Occured while generating random data using getRandom API.';
 {$ENDIF}
@@ -130,6 +130,11 @@ type
   /// <description><see href="http://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/arc4random.3">
   /// arc4random_buf</see></description>
   /// </item>
+  /// <item>
+  /// <term>DragonFly</term>
+  /// <description><see href="https://www.dragonflybsd.org/cgi/web-man?command=arc4random&amp;section=3">
+  /// arc4random_buf</see></description>
+  /// </item>
   /// </list>
   /// </summary>
   TOSRandom = class sealed(TObject)
@@ -201,8 +206,8 @@ type
     class function GenRandomBytesLinux(len: Int32; data: PByte): Int32; static;
 {$ENDIF}
     // ================================================================//
-{$IFDEF CRYPTOLIB_TRUEBSD}
-    class function GenRandomBytesTrueBSD(len: Int32; data: PByte)
+{$IFDEF CRYPTOLIB_GENERIC_BSD}
+    class function GenRandomBytesGenericBSD(len: Int32; data: PByte)
       : Int32; static;
 {$ENDIF}
     // ================================================================//
@@ -268,7 +273,7 @@ function SecRandomCopyBytes(rnd: SecRandomRef; count: LongWord; bytes: PByte)
 {$ENDIF}
 {$ENDIF}
 // ************************************************************************//
-{$IFDEF CRYPTOLIB_TRUEBSD}
+{$IFDEF CRYPTOLIB_GENERIC_BSD}
 procedure arc4random_buf(bytes: PByte; count: LongWord); cdecl; external;
 // 'c' name 'arc4random_buf';
 {$ENDIF}
@@ -516,9 +521,10 @@ begin
 end;
 
 {$ENDIF}
-{$IFDEF CRYPTOLIB_TRUEBSD}
+{$IFDEF CRYPTOLIB_GENERIC_BSD}
 
-class function TOSRandom.GenRandomBytesTrueBSD(len: Int32; data: PByte): Int32;
+class function TOSRandom.GenRandomBytesGenericBSD(len: Int32;
+  data: PByte): Int32;
 
 begin
   arc4random_buf(data, LongWord(len));
@@ -557,8 +563,8 @@ begin
     raise EAccessCryptoLibException.CreateRes(@SLinuxGetRandomError);
   end;
 
-{$ELSEIF DEFINED(CRYPTOLIB_TRUEBSD)}
-  if GenRandomBytesTrueBSD(count, PByte(data)) <> 0 then
+{$ELSEIF DEFINED(CRYPTOLIB_GENERIC_BSD)}
+  if GenRandomBytesGenericBSD(count, PByte(data)) <> 0 then
   begin
     raise EAccessCryptoLibException.CreateRes(@SArc4RandomBufGenerationError);
   end;

+ 139 - 107
README.md

@@ -1,134 +1,166 @@
-# CryptoLib4Pascal [![License](http://img.shields.io/badge/license-MIT-green.svg)](https://github.com/Xor-el/CryptoLib4Pascal/blob/master/LICENSE)
-CryptoLib4Pascal is a Cryptographic Package for Delphi/FreePascal Compilers that provides at the moment support for creating, signing and verifying DSA, ECDSA, ECNR and ECSchnorr signatures using various curves and hashes, AES, Rijndael, Blowfish and Speck Block Encryption and Decryption (With various modes and paddings), Salsa20, XSalsa20, ChaCha Stream Ciphers and ECIES.
-
-**Supported Elliptic Curves:**
-
-Curves are grouped in three different classes.
-1. NistNamed Curves
-2. SecNamed Curves (these are bare generic implementation of curves (at the moment, not as optimized as their CustomNamed Curves Counterparts))
-3. CustomNamed Curves. (these are specially optimized implementations of curves found in the previous two.)
-
-**NistNamed Curves:**
-```
-K-283, B-283, B-409, B-233, K-163, P-521, K-233, K-409, P-192, P-384, P-224, P-256, B-163, B-571, K-571.
-```
-
-**SecNamed Curves:**
-```
-sect131r1, secp160k1, sect193r1, secp384r1, secp128r1, sect163k1, sect193r2, sect239k1, sect409r1, secp256r1,
-secp521r1, sect131r2, secp112r1, sect113r2, sect163r1, secp224k1, secp224r1, sect283k1, sect233k1, sect283r1,
-sect409k1, sect571k1, secp192r1, sect233r1, secp256k1, sect571r1, secp192k1, secp160r1, sect113r1, secp160r2,
-secp112r2, sect163r2, secp128r2.
-```
-
-**CustomNamed Curves:**
-
-| curve name | alias(es) |
-|--------|--------|
-|  **secp256k1**      |        |
-|  **secp256r1**      |   **P-256**    |
-|  **secp384r1**      |   **P-384**    |
-|  **secp521r1**      |   **P-521**    |
-|  **sect283k1**      |   **K-283**    |
-
-
-**Supported Algorithms:**
-    
-    Supported signing algorithms 
-    
-    ECDSA
-    NONEwithECDSA, SHA-1withECDSA, SHA-224withECDSA, 
-    SHA-256withECDSA, SHA-384withECDSA, SHA-512withECDSA and RIPEMD160withECDSA
-    
-    ECSchnorr
-    SHA-1withECSCHNORRSIPA, SHA-224withECSCHNORRSIPA, SHA-256withECSCHNORRSIPA, SHA-384withECSCHNORRSIPA,
-    SHA-512withECSCHNORRSIPA, RIPEMD160withECSCHNORRSIPA
-    
-    
-    
-   **Dependencies:**
-   
-   [HashLib4Pascal](https://github.com/Xor-el/HashLib4Pascal) >= v2.5
-   
-   [SimpleBaseLib4Pascal](https://github.com/Xor-el/SimpleBaseLib4Pascal) >= v1.4
-    
-   For FreePascal v3.0.x [Generics.Collections](https://github.com/maciej-izak/generics.collections)
-
-**Supported Compilers**
+CryptoLib4Pascal: Crypto for Modern Object Pascal [![License](http://img.shields.io/badge/license-MIT-green.svg)](https://github.com/Xor-el/CryptoLib4Pascal/blob/master/LICENSE)
+========================================
+
+``CryptoLib4Pascal`` is an Object Pascal cryptographic library released under the permissive [MIT License](https://github.com/Xor-el/CryptoLib4Pascal/blob/master/LICENSE). 
+
+``CryptoLib4Pascal's`` goal is to be the best option for cryptography in Object Pascal by offering cryptographic recipes and primitives to Object Pascal developers.
+
+Development is coordinated on [GitHub](https://github.com/Xor-el/CryptoLib4Pascal) and contributions are welcome. If you need help, please open an issue [here](https://github.com/Xor-el/CryptoLib4Pascal/issues).
+
+
+**Build Status**
+[![Build Status](https://travis-ci.org/Xor-el/CryptoLib4Pascal.svg?branch=master)](https://travis-ci.org/Xor-el/CryptoLib4Pascal)
+
+Available Algorithms
+----------------------------------------
+
+ Symmetric Encryption
+----------------------------------------
+###### Block Ciphers
+* `AES (128, 192, and 256)` 
+
+* `Rijndael` 
+
+* `Blowfish`
+
+* `Speck`
+
+###### Stream Ciphers
+* `ChaCha`
+
+* `(X)Salsa20` 
+
+##### Cipher Modes (for applicable algorithms) 
+----------------------------------------
+
+ `ECB` `CBC` `CFB` `CTR` `CTS` `OFB` `SIC`
+
+##### Padding Modes (for applicable algorithms) 
+----------------------------------------
+
+ `ISO 10126-2` `ISO 7816-4` `Bit (ISO/IEC 9797-1)` `PKCS#5` 
  
-    FreePascal 3.0.4 and Above.
-    
-    Delphi Tokyo and Above. (might work in earlier versions though.)
+ `PKCS#7` `TBC (Trailing Bit Complement)` `ANSI X9.23` `Zero`
 
-**Installing the Library.**
+Asymmetric Cryptography
+----------------------------------------
 
-**Method One:**
+* `DSA`
 
- Use the Provided Packages in the "Packages" Folder.
+* `(DET)ECDSA (supported curves: NIST, X9.62, SEC2, Brainpool)`
 
-**Method Two:**
+* `ECNR`
 
- Add the Library Path and Sub Path to your Project Search Path.
+* `ECSchnorr`
+ 
+* `EdDSA (Ed25519, Ed25519Blake2B)`
 
-**Usage Examples.**
+Key Agreement/Exchange
+----------------------------------------
 
-    Check the "CryptoLib.Samples" folder and the Unit Tests.
+* `ECDH`
 
- **Unit Tests.**
+* `ECDHC`
+ 
+* `X25519` 
 
-To Run Unit Tests,
+Key Derivation Functions
+----------------------------------------
 
-**For FPC 3.0.4 and above**
+* `HKDF` 
+ 
+* `KDF1`
+
+* `KDF2`
 
 
-    Simply compile and run "CryptoLib.Tests" project in "FreePascal.Tests" Folder.
+Password Hashing Schemes
+----------------------------------------
 
-**For Delphi**
+* `PBKDF2`
+ 
+* `Argon2 (2i, 2d and 2id variants)`
 
-   **Method One (Using DUnit Test Runner)**
+* `Scrypt`
 
-     To Build and Run the Unit Tests For Delphi 10 Tokyo (should be similar for 
-     other versions)
-    
-    1). Open Project Options of Unit Test (CryptoLib.Tests) in "Delphi.Tests" Folder.
-    
-    2). Change Target to All Configurations (Or "Base" In Older Delphi Versions.)
-    
-    3). In Output directory add ".\$(Platform)\$(Config)" without the quotes.
-    
-    4). In Search path add "$(BDS)\Source\DUnit\src" without the quotes.
-    
-    5). In Unit output directory add "." without the quotes.
-    
-    6). In Unit scope names (If Available), Delete "DUnitX" from the List.
-    
-    Press Ok and save, then build and run.
-    
- **Method Two (Using TestInsight) (Preferred).**
+MAC
+----------------------------------------
+
+* `HMAC (all supported hashes)`
+ 
+* `X25519` 
 
-    1). Download and Install TestInsight.
-    
-    2). Open Project Options of Unit Test (CryptoLib.Tests.TestInsight) in "Delphi.Tests" 
-        Folder. 
+Hashes
+----------------------------------------
 
-    3). Change Target to All Configurations (Or "Base" In Older Delphi Versions.)
+ * `MD2`
 
-    4). In Unit scope names (If Available), Delete "DUnitX" from the List.
+ * `MD4`
 
-    5). To Use TestInsight, right-click on the project, then select 
-		"Enable for TestInsight" or "TestInsight Project".
-        Save Project then Build and Run Test Project through TestInsight. 
-        
-  **Acknowledgements**
+ * `MD5`
+
+ * `SHA-1`
+
+ * `SHA-2 (224, 256, 384, 512, 512-224, 512-256)`
+
+ * `Gost3411`
+
+ * `Gost3411-2012 (256, 512)`
+
+ * `RIPEMD (128, 256, 256, 320)`
+
+ * `Tiger`
+
+ * `WhirlPool`
+
+ * `Blake2B (160, 256, 384, 512)`
  
-Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the development of this library.
+ * `Blake2S (128, 160, 224, 256)`
+
+ * `SHA-3 (224, 256, 384, 512)`
+ 
+ * `Keccak (224, 256, 288, 384, 512)`
+
+XOF (Extensible Output Function)
+----------------------------------------
 
-**License**
+* `Shake (Shake-128, Shake-256)`
 
-This "Software" is Licensed Under  **`MIT License (MIT)`** .
+Other Useful Things
+----------------------------------------
+
+* `RNG wrappers for system RNG`
+* `ASN1 Parsing Utilities`
+
+Dependencies
+----------------------------------------
+
+* [HashLib4Pascal](https://github.com/Xor-el/HashLib4Pascal)
+* [SimpleBaseLib4Pascal](https://github.com/Xor-el/SimpleBaseLib4Pascal)
+
+Supported Compilers
+----------------------------------------
+
+* FreePascal 3.2.0+
+* Delphi Tokyo+
+
+Supported OSes
+----------------------------------------
+
+* Windows XP+
+* Linux (Including Android)
+* macOS 10.7+
+* iOS 2.0+
+* FreeBSD, NetBSD, OpenBSD and DragonBSD
+
+Acknowledgements
+----------------------------------------
+
+* Thanks to [Sphere 10 Software](http://www.sphere10.com/) for sponsoring the development of this library.
+
+Tip Jar
+----------------------------------------
 
-#### Tip Jar
 * :dollar: **Bitcoin**: `1MhFfW7tDuEHQSgie65uJcAfJgCNchGeKf`
 * :euro: **Ethereum**: `0x6c1DC21aeC49A822A4f1E3bf07c623C2C1978a98`
 * :pound: **Pascalcoin**: `345367-40`
-