Deimos binding to libsodium xor wrapper
To use this package, put the following dependency into your project's dependencies section:
Twofold binding to libsodium, current C-source version 1.0.16, released on Dec. 13, 2017 [https://github.com/jedisct1/libsodium]
subPackage 'deimos': The "import-only" C header's declarations.
subPackage 'wrapper': 'deimos' + some 'D-friendly' stuff, predominantly overloaded functions and unittests.
The dependency name is either sodium:deimos or sodium:wrapper
Some restructuring (subPackages)/changing importPath and sourcePath was done for version 0.1.0 (different from previous 0.08) in order to have the 'wrapper' subPackage sit aside subPackage 'deimos'.
Thus code that already used versions<0.1.0 needs to replace 'import sodium...' by either 'import deimos.sodium...' or 'import wrapper.sodium...'.
'wrapper' aims at providing at least the same functionality as 'deimos' and provide @trusted @nogc (pure nothrow) 'D-friendly' alternatives, that are hard to use in a wrong way; work in progress:
a) 'wrapper' is a superset of 'deimos' in that everything from 'deimos' is reachable, but deliberately not all at your fingertips.
b) all new functions with 'deimos-functionality' have the same name as their 'deimos'-cousins and call them, building either overload sets to choose from, or for parameter-less functions, 'substituting' their cousins.
c) all new functions calculating a variable-length output are restrictive referring to the size of the output-buffer offered, if the required size can be easily computed in advance, throwing in case of wrong-sized buffers.
This way, if a function succeeds, all output-buffer.length bytes are meaningful and no additional/deimos-like function out parameter carrying the meaningful length information is required.
d) No need to explicitely call sodiuminit() up-front.<br> e) Usage of 'wrapper' isn't possible, if function randombytessetimplementation shall be used (wrapper.sodium.core:shared static this() calls sodiuminit()).
The unittests of subPackage 'wrapper' include a lot of function usage examples; the next is a simple application example based on sodium:deimos, using rdmd and file cmdfile, suitable as is for Linux:
cd example/source && chmod 775 app.d && ./app.d
Expected output (byte values within brackets differing of course):
Unpredictable sequence of 8 bytes: [52, 225, 21, 245, 74, 66, 192, 247]
ciphertext: [76, 18, 112, 219, 144, 230, 206, 219, 40, 255, 78, 43, 172, 49, 129, 175, 4, 235, 81, 224]
Quoting the Sodium-manual: "Cryptographic operations in Sodium (C binary) never allocate memory on the heap (malloc, calloc, etc) with the obvious exceptions of cryptopwhash and sodiummalloc."
The same holds, if usage is restricted to sodium:deimos and also holds for many functions of sodium:wrapper.
Windows: While it get's built, I recommend to stay away from the -m32mscoff (--arch=x86mscoff) build currently:
- DUB (1.2.1) doesn't handle that correctly.
- unittest of wrapper.cryptoaeadaes256gcm.d fails for cryptoaeadaes256gcm_beforenm for some unknown reason (same compiler, code and .dll as for -m32, only import lib/format of .obj/linker differ)
- Registered by Carsten Blüggel
- 0.1.7 released 2 years ago
- ISC license
- Copyright © 2017-, Carsten Blüggel
- Sub packages:
- sodium:deimos, sodium:wrapper
0.1.7 2017-Dec-19 0.1.6 2017-Oct-30 0.1.5 2017-Sep-23 0.1.4 2017-May-10 0.1.3 2017-Apr-27
- Download Stats:
0 downloads today
0 downloads this week
10 downloads this month
1085 downloads total
- Short URL: