Compare commits

..

No commits in common. "master" and "pristine-tar" have entirely different histories.

1008 changed files with 1 additions and 168481 deletions

291
Changes
View File

@ -1,291 +0,0 @@
Changes for CryptX
0.059 2018-03-XX
- new Crypt::Digest::Keccak(224|256|384|512)
- new sign_hash_rfc7518 + verify_hash_rfc7518 (Crypt::PK::ECC)
- improved import of pkcs#8 private keys (Crypt::PK::ECC)
- fix #28 Apple's APNS pkcs8 auth key import fails (Crypt::PK::ECC)
- fix cpantesters failure (5.8.1 related)
0.058 2018-02-27
- fix: decode_b58b + invalid input
0.057 2018-01-31
- significant speed-up (more stuff handled on XS level)
- Crypt::Checksum is deprecated in favour of Crypt::Checksum::Adler32|CRC32
0.056 2017-12-22
- new Crypt::Stream::Rabbit
0.055 2017-11-28
- new Crypt::Cipher::IDEA
- new Crypt::Cipher::Serpent
- new Crypt::Stream::Salsa20
- new Crypt::Stream::Sosemanuk
- added CCM object oriented interface: new-add-add-done
- fix #39 accept CFLAGS and CPPFLAGS from the environment
- fix #40 typos in POD
- fix HMAC+SHA3 (now compliant with NIST test vectors)
0.054 2017-10-12
- fix Crypt::PK::DSA verify
- libtomcrypt updated to 1.18 (+ some extra patches)
- documentation fixes
0.053 2017-09-15
- fix Crypt::PK::DSA generate_key
0.051 2017-08-08
- INCOMPATIBLE CHANGE: Crypt::AuthEnc::OCB is now compliant with RFC 7253
0.050 2017-07-18
- fix cpantesters failures/warnings
0.049 2017-07-18
- libtomcrypt updated to 1.18-rc2 (+ some extra patches)
- REMOVED: Crypt::PK::DH encrypt decrypt sign_message verify_message sign_hash verify_hash
- NEW: Crypt::Misc - encode_b32*, decode_b32*, encode_b58*, decode_b58*
- Crypt::PK::RSA: import public key from X509 certificate
- Crypt::PK::DSA: improved generate_key()
- Crypt::PK::DH: improved generate_key()
- fix #36 aad_add is obsolete for all EncAuth algs (correct is adata_add)
- fix #37 GCM - Encryption of the empty string
0.048 2017-05-31
- NEW: Crypt::Digest::SHA3_224
- NEW: Crypt::Digest::SHA3_256
- NEW: Crypt::Digest::SHA3_384
- NEW: Crypt::Digest::SHA3_512
- NEW: Crypt::Digest::SHAKE
- NEW: Crypt::Digest::BLAKE2b_160
- NEW: Crypt::Digest::BLAKE2b_256
- NEW: Crypt::Digest::BLAKE2b_384
- NEW: Crypt::Digest::BLAKE2b_512
- NEW: Crypt::Digest::BLAKE2s_128
- NEW: Crypt::Digest::BLAKE2s_160
- NEW: Crypt::Digest::BLAKE2s_224
- NEW: Crypt::Digest::BLAKE2s_256
- NEW: Crypt::AuthEnc::ChaCha20Poly1305
- NEW: Crypt::Mac::Poly1305
- NEW: Crypt::Mac::BLAKE2s
- NEW: Crypt::Mac::BLAKE2b
- NEW: Crypt::PRNG::ChaCha20
- NEW: Crypt::Stream::ChaCha
- NEW: Crypt::Stream::RC4
- NEW: Crypt::Stream::Sober128
- NEW: functions in Crypt::Misc - increment_octets_be, increment_octets_le
- Crypt::PRNG now uses chacha20 prng by default
0.047 2017-04-05
- fix #32 Compile "ar" step fails when Perl built with -flto (better version)
- fix #33 build fails on freebsd 9.2 and 10.0 (ar: fatal: Numeric group ID too large)
0.046 2017-04-04
- fix #32 Compile "ar" step fails when Perl built with -flto
0.045 2017-03-31
- sync with libtomcrypt/develop
- fix #30 fix on SPARC+SolarisStudio
- fix #31 Fails tests without '.' in @INC
- polish compiler warnings
0.044 2016-11-28
- fix #27 Math::BigInt::LTM compatibility with older Math::BigInt
0.043 2016-11-27
- fix #26 Math::BigInt::LTM compatibility with Math::BigInt 1.999801+
0.042 2016-11-12
- RSA: sign/verify functions now support 'none' padding (INSECURE!)
- RC2: min keylen 40bit, used to be 64bit (INSECURE!)
0.041 2016-10-12
- ECC: ltc_ecc_is_point memory leak
- DSA: properly handle FIPS 186-4 (4.6 + 4.7)
- GCM: counter incrementation isn't stopped at 2^32 blocks, which breaks GCM
- fix issue #24 Crypt::PK::ECC needs $VERSION (all *.pm have $VERSION)
0.040 2016-09-12
- fix file permissions
- fix compiler warnings
0.039 2016-08-02
- fix build troubles for MacOS / PPC
0.038 2016-07-06
- fix issue #20 DSA/RSA/ECC/DH key2hash - hexadecimal numbers are missing leading zero
- Math::BigInt::LTM fixed mp_invmod(a,b,c) for b == 1
- Math::BigInt::LTM fixed _log_int()
- Math::BigInt::LTM fixed _alen()
- fix 'Please specify prototyping behavior for CryptX.xs'
- libtomcrypt (renaming *tab.c > *tab.c.inc not needed anymore)
0.037 2016-06-16
- fix issue #18 Minor issue with comment syntax
- fix issue #19 t/checksum.t fails on AIX-5.3
0.036 2016-06-07
- fix issue #17 ability to export ecc keys in short/oid form
0.035 2016-06-03
- fix issue #14 Ensure Crypt::PK::ECC->key2hash()->{curve_name} is lowercase
- fix issue #15 OpenSSL interoperability broken
0.034 2016-05-11
- Prevent RSA import_key() from altering a JWK hash reference
0.033 2016-05-09
- MSVC6 related fixes (needed for older ActivePerl@MSWin32)
0.032 2016-05-04
- Crypt::PK::DH - accept base/prime values
- new: DH methods export_key_raw, import_key_raw, params2hash
- enhanced: DH method generate_key
- new: Crypt::Checksum, Crypt::Checksum::CRC32, Crypt::Checksum::Adler32
0.031 2016-05-01
- new: RSA+ECC method export_key_jwk_thumbprint()
- new: Crypt::Misc functions random_v4uuid + is_v4uuid
- fix: RSA+ECC export_key_jwk produces canonical JSON
- fix: RSA+DSA public key export now produces PEM/DER compatible with openssl
public keys exported be previous version can still be imported
- fix: ECC import_key now accepts non-standard JWK curve names e.g. "secp112r1", "secp521r1"
0.030 2016-04-13
- fix: 0.029 + 0.028 by mistake installed *.inc files to perl/(lib|site|vendor)
0.029 2016-04-13
- NEW module: Math::BigInt::LTM
- NEW module: Crypt::Misc
0.028 2016-03-23
- IMPORTANT: switch from Module::Build to ExtUtils::MakeMaker
- fix for broken DSA key (ssh format) loading
0.027 2016-01-25
- sync with https://github.com/libtom/libtomcrypt (branch develop)
- sync with https://github.com/libtom/libtommath (branch develop)
- HP-UX related fixes
- JSON dependency is now optional (we check JSON::PP, JSON::XS, Cpanel::JSON::XS)
- skip jwk.t if no JSON::* module available
- does not require MIME::Base64 (we use base64 routines from libtomcrypt)
0.026 2015-11-28
- switch to JSON::MaybeXS
- Crypt::PRNG - rand/irand related cosmetics
- consistently using UNIX newlines
0.025 2015-07-07
- Crypt::PK::ECC+RSA export_key_jwk() allows to export a perl HASH with JWK structure
0.024 2015-06-29
- new Crypt::PK::ECC methods
verify_message_rfc7518()
sign_message_rfc7518()
curve2hash()
- fix for Crypt::PK::RSA - bug in loading private key in JWK format
0.023 2015-06-10
- support for older compilers (gcc3, vc6)
- typo in documentation (by tomhukins)
0.022 2015-05-22
- new: Crypt::PK::ECC+RSA export_key_jwk() - exporting JWK format
- new: Crypt::Digest::SHA512_224
- new: Crypt::Digest::SHA512_256
- Crypt::PK::ECC+RSA import_key() - support for:
* public/private keys in JWK format
* private keys in PKCS8 PEM/DER format (unencrypted only)
- Crypt::PK::ECC+RSA+DSA import_key() - support for:
* public keys in SSH format
* public/private keys as a hashref exported via key2hash
- libtomcrypt updated to the latest develop branch, commit aeaa6d4a51 Apr 17 08:59:35 2015 +0200
- libtommath updated to the latest develop branch, commit 0fd5e6c17f Dec 11 14:59:35 2014 +0100
- documentation fixes
0.021 2014-01-23
- fixed asm(...) related compiler failures
- dsa_encrypt_key small correction
- optimized ecc_encrypt_key
0.020 2014-01-18
- INCOMPATIBLE CHANGE: huge redesign of Crypt::PK::ECC
- ECC now supports curves y^2 = x^3 + a*x + b
- ECC you can use custom curves
- ECC import/export of keys in DER/PEM format now compatible with openssl
- enabling compile options ASM + ECC_TIMING_RESISTANT
- added many test vectors (RSA, DSA, EC) for interoperability with openssl
0.019 2013-10-20
- fixed broken CAMELLIA implementation
0.018 2013-10-18
- DSA: make_key + sign_hash fixes
0.017 2013-09-24
- lowering MIME::Base64 version requirement
- support for import/export of password protected RSA/DSA keys
- RSA: added - export_key_pem('public_x509')
- better handling of dh_free/rsa_free/dsa_free/ecc_free
- added openssl test vectors
- fixed compiler warnings (RSA/DSA/ECC/DH)
0.016 2013-09-15
- added missing test for key2hash, sign_hash, verify_hash
- fixed build failures on VC6
0.015 2013-09-12
- only documentation fixes
0.014 2013-09-11
- Crypt::Digest::NNN + Crypt::Mac::NNN - can produce Base64-URL-Safe encoded digest/mac
- Crypt::PRNG + Crypt::PRNG::NNN - Base64-URL-Safe encoded random bytes (random_bytes_b64u/bytes_b64u)
- Crypt::PK::RSA/DSA/DH/ECC - sign/verify replaced by sign_message/verify_message + sign_hash/verify_hash
- Crypt::PK::RSA/DSA/DH/ECC - new method key2hash
- documentation fixes
0.013 2013-08-28
- DSA/RSA/ECC/DH - importing keys from string changed - now: $pk->import_key(\$buffer_with_key)
- DSA/RSA/ECC/DH - size() and is_private() now return undef if no key loaded
- improved RSA doc
0.012 2013-06-17
- README, LICENSE etc. to improve CPANTS score
- somehow works with perl 5.6.2
0.011 2013-06-15
- fixing various compiler warnings
0.009 2013-05-19
- doc fixes
- requires perl 5.8.8 or higher
- INCOMPATIBILITY: all digest related 'xxx_base64' functions renamed to 'xxx_b64'
0.008 2013-05-02
- fixed prng test failures
- Crypt::Digest::* croaks with the "real caller" (not a nice solution)
0.007 2013-04-23
- Crypt::PRNG supports add_entropy() - without params
- Crypt::PRNG fork-safe & thread-safe
- random_string has default $len = 20
- doc fixes
- cpan tester failure fix for pk_dsa.t
0.006 2013-04-19
- added Crypt::KeyDerivation
- Win64 compatibility
0.005 2013-04-18
- added Crypt::PRNG::Fortuna|RC4|Sober128|Yarrow
- added Crypt::PK::RSA|DSA|ECC|DH
0.004 2013-04-16
- removing illegal Crypt::Random
0.003 2013-04-16
- added Crypt::Mode::CBC|CFB|CTR|ECB|OFB
- added Crypt::AuthEnc::CCM|EAX|GCM|OCB
0.002 2013-04-11
- first release on CPAN

767
CryptX.xs
View File

@ -1,767 +0,0 @@
#define PERL_NO_GET_CONTEXT /* we want efficiency */
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#define NEED_sv_2pvbyte_GLOBAL
#define NEED_sv_2pv_flags_GLOBAL
#define NEED_newRV_noinc_GLOBAL
#include "ppport.h"
/* assert_not_ROK is broken in 5.8.1 */
#if PERL_VERSION == 8 && PERL_SUBVERSION == 1
# undef assert_not_ROK
# if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
# define assert_not_ROK(sv) ({assert(!SvROK(sv) || !SvRV(sv));}),
# else
# define assert_not_ROK(sv)
# endif
#endif
#undef LTC_SOURCE
#include "tomcrypt.h"
#include "tommath.h"
typedef adler32_state *Crypt__Checksum__Adler32;
typedef crc32_state *Crypt__Checksum__CRC32;
typedef ccm_state *Crypt__AuthEnc__CCM;
typedef eax_state *Crypt__AuthEnc__EAX;
typedef gcm_state *Crypt__AuthEnc__GCM;
typedef chacha20poly1305_state *Crypt__AuthEnc__ChaCha20Poly1305;
typedef ocb3_state *Crypt__AuthEnc__OCB;
typedef chacha_state *Crypt__Stream__ChaCha;
typedef salsa20_state *Crypt__Stream__Salsa20;
typedef sosemanuk_state *Crypt__Stream__Sosemanuk;
typedef rabbit_state *Crypt__Stream__Rabbit;
typedef rc4_state *Crypt__Stream__RC4;
typedef sober128_state *Crypt__Stream__Sober128;
typedef f9_state *Crypt__Mac__F9;
typedef hmac_state *Crypt__Mac__HMAC;
typedef omac_state *Crypt__Mac__OMAC;
typedef pelican_state *Crypt__Mac__Pelican;
typedef pmac_state *Crypt__Mac__PMAC;
typedef xcbc_state *Crypt__Mac__XCBC;
typedef poly1305_state *Crypt__Mac__Poly1305;
typedef blake2smac_state *Crypt__Mac__BLAKE2s;
typedef blake2bmac_state *Crypt__Mac__BLAKE2b;
typedef struct cipher_struct { /* used by Crypt::Cipher */
symmetric_key skey;
struct ltc_cipher_descriptor *desc;
} *Crypt__Cipher;
typedef struct digest_struct { /* used by Crypt::Digest */
hash_state state;
struct ltc_hash_descriptor *desc;
} *Crypt__Digest;
typedef struct digest_shake_struct { /* used by Crypt::Digest::SHAKE */
hash_state state;
int num;
} *Crypt__Digest__SHAKE;
typedef struct cbc_struct { /* used by Crypt::Mode::CBC */
int cipher_id, cipher_rounds;
symmetric_CBC state;
unsigned char pad[MAXBLOCKSIZE];
int padlen;
int padding_mode;
int direction;
} *Crypt__Mode__CBC;
typedef struct ecb_struct { /* used by Crypt::Mode::ECB */
int cipher_id, cipher_rounds;
symmetric_ECB state;
unsigned char pad[MAXBLOCKSIZE];
int padlen;
int padding_mode;
int direction;
} *Crypt__Mode__ECB;
typedef struct cfb_struct { /* used by Crypt::Mode::CFB */
int cipher_id, cipher_rounds;
symmetric_CFB state;
int direction;
} *Crypt__Mode__CFB;
typedef struct ctr_struct { /* used by Crypt::Mode::CTR */
int cipher_id, cipher_rounds;
int ctr_mode_param;
symmetric_CTR state;
int direction;
} *Crypt__Mode__CTR;
typedef struct f8_struct { /* used by Crypt::Mode::F8 */
int cipher_id, cipher_rounds;
symmetric_F8 state;
int direction;
} *Crypt__Mode__F8;
typedef struct lrw_struct { /* used by Crypt::Mode::LRW */
int cipher_id, cipher_rounds;
symmetric_LRW state;
int direction;
} *Crypt__Mode__LRW;
typedef struct ofb_struct { /* used by Crypt::Mode::OFB */
int cipher_id, cipher_rounds;
symmetric_OFB state;
int direction;
} *Crypt__Mode__OFB;
typedef struct xts_struct { /* used by Crypt::Mode::XTS */
int cipher_id, cipher_rounds;
symmetric_xts state;
int direction;
} *Crypt__Mode__XTS;
typedef struct prng_struct { /* used by Crypt::PRNG */
prng_state state;
struct ltc_prng_descriptor *desc;
IV last_pid;
} *Crypt__PRNG;
typedef struct rsa_struct { /* used by Crypt::PK::RSA */
prng_state pstate;
int pindex;
rsa_key key;
} *Crypt__PK__RSA;
typedef struct dsa_struct { /* used by Crypt::PK::DSA */
prng_state pstate;
int pindex;
dsa_key key;
} *Crypt__PK__DSA;
typedef struct dh_struct { /* used by Crypt::PK::DH */
prng_state pstate;
int pindex;
dh_key key;
} *Crypt__PK__DH;
typedef struct ecc_struct { /* used by Crypt::PK::ECC */
prng_state pstate;
int pindex;
ecc_key key;
} *Crypt__PK__ECC;
int mp_tohex_with_leading_zero(mp_int * a, char *str, int maxlen, int minlen) {
int len, rv;
if (mp_isneg(a) == MP_YES) {
*str = '\0';
return MP_VAL;
}
rv = mp_toradix_n(a, str, 16, maxlen);
if (rv != MP_OKAY) {
*str = '\0';
return rv;
}
len = (int)strlen(str);
if (len > 0 && len % 2 && len < maxlen-2) {
memmove(str+1, str, len+1); /* incl. NUL byte */
*str = '0'; /* add leading zero */
}
len = (int)strlen(str);
if (len < minlen && minlen < maxlen-1) {
memmove(str+(minlen-len), str, len+1); /* incl. NUL byte */
memset(str, '0', minlen-len); /* add leading zero */
}
return MP_OKAY;
}
int _base16_encode(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen)
{
unsigned long i;
const char alphabet[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
if (*outlen < inlen * 2) {
*outlen = inlen * 2;
return CRYPT_BUFFER_OVERFLOW;
}
for (i = 0; i < inlen; i++) {
out[i*2] = (unsigned char)alphabet[in[i] >> 4];
out[i*2+1] = (unsigned char)alphabet[in[i] & 0xF];
}
*outlen = inlen * 2;
return CRYPT_OK;
}
size_t _find_start(const char *name, char *ltcname, size_t ltclen)
{
size_t i, start = 0;
if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ;
/* normalize */
for (i = 0; i < ltclen && name[i] > 0; i++) {
if (name[i] >= 'A' && name[i] <= 'Z') {
ltcname[i] = name[i] + 32; /* lowecase */
}
else if (name[i] == '_') {
ltcname[i] = '-';
}
else {
ltcname[i] = name[i];
}
if (name[i] == ':') start = i + 1;
}
return start;
}
int _find_hash(const char *name)
{
char ltcname[100] = { 0 };
size_t start = _find_start(name, ltcname, sizeof(ltcname) - 1);
/* special cases */
if (strcmp(ltcname + start, "ripemd128") == 0) return find_hash("rmd128");
if (strcmp(ltcname + start, "ripemd160") == 0) return find_hash("rmd160");
if (strcmp(ltcname + start, "ripemd256") == 0) return find_hash("rmd256");
if (strcmp(ltcname + start, "ripemd320") == 0) return find_hash("rmd320");
if (strcmp(ltcname + start, "tiger192") == 0) return find_hash("tiger");
if (strcmp(ltcname + start, "chaes") == 0) return find_hash("chc_hash");
if (strcmp(ltcname + start, "chc-hash") == 0) return find_hash("chc_hash");
return find_hash(ltcname + start);
}
int _find_cipher(const char *name)
{
char ltcname[100] = { 0 };
size_t start = _find_start(name, ltcname, sizeof(ltcname) - 1);
/* special cases */
if (strcmp(ltcname + start, "des-ede") == 0) return find_cipher("3des");
if (strcmp(ltcname + start, "saferp") == 0) return find_cipher("safer+");
return find_cipher(ltcname + start);
}
int _find_prng(const char *name)
{
char ltcname[100] = { 0 };
size_t start = _find_start(name, ltcname, sizeof(ltcname) - 1);
return find_prng(ltcname + start);
}
/* Math::BigInt::LTM related */
typedef mp_int * Math__BigInt__LTM;
STATIC SV * sv_from_mpi(mp_int *mpi) {
dTHX; /* fetch context */
SV *obj = newSV(0);
sv_setref_pv(obj, "Math::BigInt::LTM", (void*)mpi);
return obj;
}
void _ecc_oid_lookup(ecc_key *key)
{
int err;
unsigned i;
void *tmp;
const ltc_ecc_set_type *set;
key->dp.oidlen = 0;
if ((err = ltc_mp.init(&tmp)) != CRYPT_OK) return;
for (set = ltc_ecc_sets; set->name != NULL; set++) {
if ((err = mp_read_radix(tmp, set->prime, 16)) != CRYPT_OK) continue;
if ((mp_cmp(tmp, key->dp.prime) != LTC_MP_EQ)) continue;
if ((err = mp_read_radix(tmp, set->order, 16)) != CRYPT_OK) continue;
if ((mp_cmp(tmp, key->dp.order) != LTC_MP_EQ)) continue;
if ((err = mp_read_radix(tmp, set->A, 16)) != CRYPT_OK) continue;
if ((mp_cmp(tmp, key->dp.A) != LTC_MP_EQ)) continue;
if ((err = mp_read_radix(tmp, set->B, 16)) != CRYPT_OK) continue;
if ((mp_cmp(tmp, key->dp.B) != LTC_MP_EQ)) continue;
if ((err = mp_read_radix(tmp, set->Gx, 16)) != CRYPT_OK) continue;
if ((mp_cmp(tmp, key->dp.base.x) != LTC_MP_EQ)) continue;
if ((err = mp_read_radix(tmp, set->Gy, 16)) != CRYPT_OK) continue;
if ((mp_cmp(tmp, key->dp.base.y) != LTC_MP_EQ)) continue;
if (key->dp.cofactor != set->cofactor) continue;
break; /* found */
}
ltc_mp.deinit(tmp);
if (set->name != NULL) {
key->dp.oidlen = set->oidlen;
for(i = 0; i < set->oidlen; i++) key->dp.oid[i] = set->oid[i];
}
}
int _ecc_set_dp_from_SV(ecc_key *key, SV *curve)
{
dTHX; /* fetch context */
HV *hc, *hl, *h;
SV *sv_crv, **pref;
SV **sv_cofactor, **sv_prime, **sv_A, **sv_B, **sv_order, **sv_Gx, **sv_Gy, **sv_oid;
char *ch_name;
STRLEN l_name, i, j;
int err;
if (!SvOK(curve)) croak("FATAL: undefined curve");
if (SvPOK(curve)) {
/* string */
ch_name = SvPV(curve, l_name);
if ((hl = get_hv("Crypt::PK::ECC::curve2ltc", 0)) == NULL) croak("FATAL: no curve2ltc register");
pref = hv_fetch(hl, ch_name, (U32)l_name, 0);
if (pref && SvOK(*pref)) {
sv_crv = *pref; /* found in %cutve2ltc */
}
else {
if ((hc = get_hv("Crypt::PK::ECC::curve", 0)) == NULL) croak("FATAL: no curve register");
pref = hv_fetch(hc, ch_name, (U32)l_name, 0);
if (pref && SvOK(*pref)) {
sv_crv = *pref; /* found in %curve */
}
else {
sv_crv = curve;
}
}
}
else if (SvROK(curve)) {
/* hashref */
sv_crv = curve;
}
else {
croak("FATAL: curve has to be a string or a hashref");
}
if (SvPOK(sv_crv)) {
/* string - curve name */
const ltc_ecc_set_type *dp;
ch_name = SvPV(sv_crv, l_name);
if (ecc_get_set_by_name(ch_name, &dp) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ch_name);
return ecc_set_dp(dp, key);
}
else {
/* hashref */
ltc_ecc_set_type set = { 0 };
if ((h = (HV*)(SvRV(sv_crv))) == NULL) croak("FATAL: ecparams: param is not valid hashref");
if ((sv_prime = hv_fetchs(h, "prime", 0)) == NULL) croak("FATAL: ecparams: missing param prime");
if ((sv_A = hv_fetchs(h, "A", 0)) == NULL) croak("FATAL: ecparams: missing param A");
if ((sv_B = hv_fetchs(h, "B", 0)) == NULL) croak("FATAL: ecparams: missing param B");
if ((sv_order = hv_fetchs(h, "order", 0)) == NULL) croak("FATAL: ecparams: missing param order");
if ((sv_Gx = hv_fetchs(h, "Gx", 0)) == NULL) croak("FATAL: ecparams: missing param Gx");
if ((sv_Gy = hv_fetchs(h, "Gy", 0)) == NULL) croak("FATAL: ecparams: missing param Gy");
if ((sv_cofactor = hv_fetchs(h, "cofactor", 0)) == NULL) croak("FATAL: ecparams: missing param cofactor");
if (!SvOK(*sv_prime )) croak("FATAL: ecparams: undefined param prime");
if (!SvOK(*sv_A )) croak("FATAL: ecparams: undefined param A");
if (!SvOK(*sv_B )) croak("FATAL: ecparams: undefined param B");
if (!SvOK(*sv_order )) croak("FATAL: ecparams: undefined param order");
if (!SvOK(*sv_Gx )) croak("FATAL: ecparams: undefined param Gx");
if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy");
if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor");
set.prime = SvPV_nolen(*sv_prime);
set.A = SvPV_nolen(*sv_A);
set.B = SvPV_nolen(*sv_B);
set.order = SvPV_nolen(*sv_order);
set.Gx = SvPV_nolen(*sv_Gx);
set.Gy = SvPV_nolen(*sv_Gy);
set.cofactor = (unsigned long)SvUV(*sv_cofactor),
set.name = NULL;
set.oidlen = 0;
sv_oid = hv_fetchs(h, "oid", 0);
if (sv_oid && SvPOK(*sv_oid)) {
ch_name = SvPV(*sv_oid, l_name);
for (i = 0, j = 0; i < l_name; i++) {
if (ch_name[i] == '.') {
if (++j >= 16) return CRYPT_ERROR;
}
else if(ch_name[i] >= '0' && ch_name[i] <= '9') {
set.oid[j] = set.oid[j] * 10 + (ch_name[i] - '0');
}
else {
return CRYPT_ERROR;
}
}
if (j == 0) return CRYPT_ERROR;
set.oidlen = j + 1;
}
if ((err = ecc_set_dp(&set, key)) != CRYPT_OK) return err;
if (key->dp.oidlen == 0) _ecc_oid_lookup(key);
return CRYPT_OK;
}
}
MODULE = CryptX PACKAGE = CryptX PREFIX = CryptX_
PROTOTYPES: DISABLE
BOOT:
if(register_all_ciphers() != CRYPT_OK) { croak("FATAL: register_all_ciphers failed"); }
if(register_all_hashes() != CRYPT_OK) { croak("FATAL: register_all_hashes failed"); }
if(register_all_prngs() != CRYPT_OK) { croak("FATAL: register_all_prngs failed"); }
if(crypt_mp_init("ltm") != CRYPT_OK) { croak("FATAL: crypt_mp_init failed"); }
SV *
CryptX__ltc_build_settings()
CODE:
RETVAL = newSVpv(crypt_build_settings, 0);
OUTPUT:
RETVAL
SV *
CryptX__ltc_mp_name()
CODE:
RETVAL = newSVpv(ltc_mp.name, 0);
OUTPUT:
RETVAL
int
CryptX__ltc_mp_bits_per_digit()
CODE:
RETVAL = ltc_mp.bits_per_digit;
OUTPUT:
RETVAL
MODULE = CryptX PACKAGE = Crypt::Misc
PROTOTYPES: DISABLE
SV *
_radix_to_bin(char *in, int radix)
CODE:
{
STRLEN len;
unsigned char *out_data;
mp_int mpi;
if (in == NULL) XSRETURN_UNDEF;
if (mp_init(&mpi) != CRYPT_OK) XSRETURN_UNDEF;
if (strlen(in) == 0) {
RETVAL = newSVpvn("", 0);
}
else if (mp_read_radix(&mpi, in, radix) == CRYPT_OK) {
len = mp_unsigned_bin_size(&mpi);
if (len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, len);
out_data = (unsigned char *)SvPVX(RETVAL);
mp_to_unsigned_bin(&mpi, out_data);
}
}
else {
RETVAL = newSVpvn(NULL, 0); /* undef */
}
mp_clear(&mpi);
}
OUTPUT:
RETVAL
SV *
_bin_to_radix(SV *in, int radix)
CODE:
{
STRLEN len;
unsigned char *in_data;
char *out_data;
mp_int mpi, tmp;
mp_digit d;
int digits = 0;
if (!SvPOK(in) || radix < 2 || radix > 64) XSRETURN_UNDEF;
in_data = (unsigned char *) SvPVbyte(in, len);
mp_init_multi(&mpi, &tmp, NULL);
if (len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
if (mp_read_unsigned_bin(&mpi, in_data, (unsigned long)len) == CRYPT_OK) {
mp_copy(&mpi, &tmp);
while (mp_iszero(&tmp) == MP_NO) {
mp_div_d(&tmp, (mp_digit)radix, &tmp, &d);
digits++;
}
if (digits == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, digits + 2); /* +2 for sign and NUL byte */
SvPOK_only(RETVAL);
out_data = SvPVX(RETVAL);
mp_toradix(&mpi, out_data, radix);
SvCUR_set(RETVAL, strlen(out_data));
}
}
else {
RETVAL = newSVpvn(NULL, 0); /* undef */
}
}
mp_clear_multi(&tmp, &mpi, NULL);
}
OUTPUT:
RETVAL
SV *
encode_b64(SV * in)
ALIAS:
encode_b64u = 1
CODE:
{
int rv;
STRLEN in_len;
unsigned long out_len;
unsigned char *out_data, *in_data;
if (!SvPOK(in)) XSRETURN_UNDEF;
in_data = (unsigned char *) SvPVbyte(in, in_len);
if (in_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
out_len = (unsigned long)(4 * ((in_len + 2) / 3) + 1);
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
out_data = (unsigned char *)SvPVX(RETVAL);
if (ix == 1)
rv = base64url_encode(in_data, (unsigned long)in_len, out_data, &out_len);
else
rv = base64_encode(in_data, (unsigned long)in_len, out_data, &out_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
XSRETURN_UNDEF;
}
SvCUR_set(RETVAL, out_len);
}
}
OUTPUT:
RETVAL
SV *
decode_b64(SV * in)
ALIAS:
decode_b64u = 1
CODE:
{
int rv;
STRLEN in_len;
unsigned long out_len;
unsigned char *out_data, *in_data;
if (!SvPOK(in)) XSRETURN_UNDEF;
in_data = (unsigned char *)SvPVbyte(in, in_len);
if (in_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
out_len = (unsigned long)in_len;
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
out_data = (unsigned char *)SvPVX(RETVAL);
if (ix == 1)
rv = base64url_decode(in_data, (unsigned long)in_len, out_data, &out_len);
else
rv = base64_decode(in_data, (unsigned long)in_len, out_data, &out_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
XSRETURN_UNDEF;
}
SvCUR_set(RETVAL, out_len);
}
}
OUTPUT:
RETVAL
SV *
encode_b32r(SV *in)
ALIAS:
encode_b32b = 1
encode_b32z = 2
encode_b32c = 3
CODE:
{
STRLEN in_len;
unsigned long out_len;
unsigned char *out_data, *in_data;
int id = -1;
if (!SvPOK(in)) XSRETURN_UNDEF;
if (ix == 0) id = BASE32_RFC4648;
if (ix == 1) id = BASE32_BASE32HEX;
if (ix == 2) id = BASE32_ZBASE32;
if (ix == 3) id = BASE32_CROCKFORD;
if (id == -1) XSRETURN_UNDEF;
in_data = (unsigned char *) SvPVbyte(in, in_len);
if (in_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
out_len = (unsigned long)((8 * in_len + 4) / 5);
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
out_data = (unsigned char *)SvPVX(RETVAL);
if (base32_encode(in_data, (unsigned long)in_len, out_data, &out_len, id) != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
XSRETURN_UNDEF;
}
SvCUR_set(RETVAL, out_len);
}
}
OUTPUT:
RETVAL
SV *
decode_b32r(SV *in)
ALIAS:
decode_b32b = 1
decode_b32z = 2
decode_b32c = 3
CODE:
{
STRLEN in_len;
unsigned long out_len;
unsigned char *out_data, *in_data;
int id = -1;
if (!SvPOK(in)) XSRETURN_UNDEF;
if (ix == 0) id = BASE32_RFC4648;
if (ix == 1) id = BASE32_BASE32HEX;
if (ix == 2) id = BASE32_ZBASE32;
if (ix == 3) id = BASE32_CROCKFORD;
if (id == -1) XSRETURN_UNDEF;
in_data = (unsigned char *)SvPVbyte(in, in_len);
if (in_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
out_len = (unsigned long)in_len;
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
out_data = (unsigned char *)SvPVX(RETVAL);
if (base32_decode(in_data, (unsigned long)in_len, out_data, &out_len, id) != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
XSRETURN_UNDEF;
}
SvCUR_set(RETVAL, out_len);
}
}
OUTPUT:
RETVAL
SV *
increment_octets_le(SV * in)
CODE:
{
STRLEN len, i = 0;
unsigned char *out_data, *in_data;
if (!SvPOK(in)) XSRETURN_UNDEF;
in_data = (unsigned char *)SvPVbyte(in, len);
if (len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, len);
out_data = (unsigned char *)SvPVX(RETVAL);
Copy(in_data, out_data, len, unsigned char);
while (i < len) {
out_data[i]++;
if (0 != out_data[i]) break;
i++;
}
if (i == len) {
SvREFCNT_dec(RETVAL);
croak("FATAL: increment_octets_le overflow");
}
}
}
OUTPUT:
RETVAL
SV *
increment_octets_be(SV * in)
CODE:
{
STRLEN len, i = 0;
unsigned char *out_data, *in_data;
if (!SvPOK(in)) XSRETURN_UNDEF;
in_data = (unsigned char *)SvPVbyte(in, len);
if (len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, len);
out_data = (unsigned char *)SvPVX(RETVAL);
Copy(in_data, out_data, len, unsigned char);
while (i < len) {
out_data[len - 1 - i]++;
if (0 != out_data[len - 1 - i]) break;
i++;
}
if (i == len) {
SvREFCNT_dec(RETVAL);
croak("FATAL: increment_octets_be overflow");
}
}
}
OUTPUT:
RETVAL
###############################################################################
INCLUDE: inc/CryptX_Digest.xs.inc
INCLUDE: inc/CryptX_Digest_SHAKE.xs.inc
INCLUDE: inc/CryptX_Cipher.xs.inc
INCLUDE: inc/CryptX_Checksum_Adler32.xs.inc
INCLUDE: inc/CryptX_Checksum_CRC32.xs.inc
INCLUDE: inc/CryptX_AuthEnc_EAX.xs.inc
INCLUDE: inc/CryptX_AuthEnc_GCM.xs.inc
INCLUDE: inc/CryptX_AuthEnc_OCB.xs.inc
INCLUDE: inc/CryptX_AuthEnc_CCM.xs.inc
INCLUDE: inc/CryptX_AuthEnc_ChaCha20Poly1305.xs.inc
INCLUDE: inc/CryptX_Stream_ChaCha.xs.inc
INCLUDE: inc/CryptX_Stream_Salsa20.xs.inc
INCLUDE: inc/CryptX_Stream_RC4.xs.inc
INCLUDE: inc/CryptX_Stream_Sober128.xs.inc
INCLUDE: inc/CryptX_Stream_Sosemanuk.xs.inc
INCLUDE: inc/CryptX_Stream_Rabbit.xs.inc
INCLUDE: inc/CryptX_Mac_F9.xs.inc
INCLUDE: inc/CryptX_Mac_HMAC.xs.inc
INCLUDE: inc/CryptX_Mac_OMAC.xs.inc
INCLUDE: inc/CryptX_Mac_Pelican.xs.inc
INCLUDE: inc/CryptX_Mac_PMAC.xs.inc
INCLUDE: inc/CryptX_Mac_XCBC.xs.inc
INCLUDE: inc/CryptX_Mac_Poly1305.xs.inc
INCLUDE: inc/CryptX_Mac_BLAKE2s.xs.inc
INCLUDE: inc/CryptX_Mac_BLAKE2b.xs.inc
INCLUDE: inc/CryptX_Mode_CBC.xs.inc
INCLUDE: inc/CryptX_Mode_ECB.xs.inc
INCLUDE: inc/CryptX_Mode_CFB.xs.inc
INCLUDE: inc/CryptX_Mode_OFB.xs.inc
INCLUDE: inc/CryptX_Mode_CTR.xs.inc
#INCLUDE: inc/CryptX_Mode_F8.xs.inc
#INCLUDE: inc/CryptX_Mode_LRW.xs.inc
#INCLUDE: inc/CryptX_Mode_XTS.xs.inc
INCLUDE: inc/CryptX_PRNG.xs.inc
INCLUDE: inc/CryptX_PK_RSA.xs.inc
INCLUDE: inc/CryptX_PK_DSA.xs.inc
INCLUDE: inc/CryptX_PK_DH.xs.inc
INCLUDE: inc/CryptX_PK_ECC.xs.inc
INCLUDE: inc/CryptX_KeyDerivation.xs.inc
INCLUDE: inc/CryptX_BigInt_LTM.xs.inc

View File

@ -1 +0,0 @@
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

998
MANIFEST
View File

@ -1,998 +0,0 @@
Changes
CryptX.xs
inc/CryptX_AuthEnc_CCM.xs.inc
inc/CryptX_AuthEnc_ChaCha20Poly1305.xs.inc
inc/CryptX_AuthEnc_EAX.xs.inc
inc/CryptX_AuthEnc_GCM.xs.inc
inc/CryptX_AuthEnc_OCB.xs.inc
inc/CryptX_BigInt_LTM.xs.inc
inc/CryptX_Checksum_Adler32.xs.inc
inc/CryptX_Checksum_CRC32.xs.inc
inc/CryptX_Cipher.xs.inc
inc/CryptX_Digest.xs.inc
inc/CryptX_Digest_SHAKE.xs.inc
inc/CryptX_KeyDerivation.xs.inc
inc/CryptX_Mac_BLAKE2b.xs.inc
inc/CryptX_Mac_BLAKE2s.xs.inc
inc/CryptX_Mac_F9.xs.inc
inc/CryptX_Mac_HMAC.xs.inc
inc/CryptX_Mac_OMAC.xs.inc
inc/CryptX_Mac_Pelican.xs.inc
inc/CryptX_Mac_PMAC.xs.inc
inc/CryptX_Mac_Poly1305.xs.inc
inc/CryptX_Mac_XCBC.xs.inc
inc/CryptX_Mode_CBC.xs.inc
inc/CryptX_Mode_CFB.xs.inc
inc/CryptX_Mode_CTR.xs.inc
inc/CryptX_Mode_ECB.xs.inc
inc/CryptX_Mode_OFB.xs.inc
inc/CryptX_PK_DH.xs.inc
inc/CryptX_PK_DSA.xs.inc
inc/CryptX_PK_ECC.xs.inc
inc/CryptX_PK_RSA.xs.inc
inc/CryptX_PRNG.xs.inc
inc/CryptX_Stream_ChaCha.xs.inc
inc/CryptX_Stream_Rabbit.xs.inc
inc/CryptX_Stream_RC4.xs.inc
inc/CryptX_Stream_Salsa20.xs.inc
inc/CryptX_Stream_Sober128.xs.inc
inc/CryptX_Stream_Sosemanuk.xs.inc
lib/Crypt/AuthEnc.pm
lib/Crypt/AuthEnc/CCM.pm
lib/Crypt/AuthEnc/ChaCha20Poly1305.pm
lib/Crypt/AuthEnc/EAX.pm
lib/Crypt/AuthEnc/GCM.pm
lib/Crypt/AuthEnc/OCB.pm
lib/Crypt/Checksum.pm
lib/Crypt/Checksum/Adler32.pm
lib/Crypt/Checksum/CRC32.pm
lib/Crypt/Cipher.pm
lib/Crypt/Cipher/AES.pm
lib/Crypt/Cipher/Anubis.pm
lib/Crypt/Cipher/Blowfish.pm
lib/Crypt/Cipher/Camellia.pm
lib/Crypt/Cipher/CAST5.pm
lib/Crypt/Cipher/DES.pm
lib/Crypt/Cipher/DES_EDE.pm
lib/Crypt/Cipher/IDEA.pm
lib/Crypt/Cipher/KASUMI.pm
lib/Crypt/Cipher/Khazad.pm
lib/Crypt/Cipher/MULTI2.pm
lib/Crypt/Cipher/Noekeon.pm
lib/Crypt/Cipher/RC2.pm
lib/Crypt/Cipher/RC5.pm
lib/Crypt/Cipher/RC6.pm
lib/Crypt/Cipher/SAFER_K128.pm
lib/Crypt/Cipher/SAFER_K64.pm
lib/Crypt/Cipher/SAFER_SK128.pm
lib/Crypt/Cipher/SAFER_SK64.pm
lib/Crypt/Cipher/SAFERP.pm
lib/Crypt/Cipher/SEED.pm
lib/Crypt/Cipher/Serpent.pm
lib/Crypt/Cipher/Skipjack.pm
lib/Crypt/Cipher/Twofish.pm
lib/Crypt/Cipher/XTEA.pm
lib/Crypt/Digest.pm
lib/Crypt/Digest/BLAKE2b_160.pm
lib/Crypt/Digest/BLAKE2b_256.pm
lib/Crypt/Digest/BLAKE2b_384.pm
lib/Crypt/Digest/BLAKE2b_512.pm
lib/Crypt/Digest/BLAKE2s_128.pm
lib/Crypt/Digest/BLAKE2s_160.pm
lib/Crypt/Digest/BLAKE2s_224.pm
lib/Crypt/Digest/BLAKE2s_256.pm
lib/Crypt/Digest/CHAES.pm
lib/Crypt/Digest/Keccak224.pm
lib/Crypt/Digest/Keccak256.pm
lib/Crypt/Digest/Keccak384.pm
lib/Crypt/Digest/Keccak512.pm
lib/Crypt/Digest/MD2.pm
lib/Crypt/Digest/MD4.pm
lib/Crypt/Digest/MD5.pm
lib/Crypt/Digest/RIPEMD128.pm
lib/Crypt/Digest/RIPEMD160.pm
lib/Crypt/Digest/RIPEMD256.pm
lib/Crypt/Digest/RIPEMD320.pm
lib/Crypt/Digest/SHA1.pm
lib/Crypt/Digest/SHA224.pm
lib/Crypt/Digest/SHA256.pm
lib/Crypt/Digest/SHA384.pm
lib/Crypt/Digest/SHA3_224.pm
lib/Crypt/Digest/SHA3_256.pm
lib/Crypt/Digest/SHA3_384.pm
lib/Crypt/Digest/SHA3_512.pm
lib/Crypt/Digest/SHA512.pm
lib/Crypt/Digest/SHA512_224.pm
lib/Crypt/Digest/SHA512_256.pm
lib/Crypt/Digest/SHAKE.pm
lib/Crypt/Digest/Tiger192.pm
lib/Crypt/Digest/Whirlpool.pm
lib/Crypt/KeyDerivation.pm
lib/Crypt/Mac.pm
lib/Crypt/Mac/BLAKE2b.pm
lib/Crypt/Mac/BLAKE2s.pm
lib/Crypt/Mac/F9.pm
lib/Crypt/Mac/HMAC.pm
lib/Crypt/Mac/OMAC.pm
lib/Crypt/Mac/Pelican.pm
lib/Crypt/Mac/PMAC.pm
lib/Crypt/Mac/Poly1305.pm
lib/Crypt/Mac/XCBC.pm
lib/Crypt/Misc.pm
lib/Crypt/Mode.pm
lib/Crypt/Mode/CBC.pm
lib/Crypt/Mode/CFB.pm
lib/Crypt/Mode/CTR.pm
lib/Crypt/Mode/ECB.pm
lib/Crypt/Mode/OFB.pm
lib/Crypt/PK.pm
lib/Crypt/PK/DH.pm
lib/Crypt/PK/DSA.pm
lib/Crypt/PK/ECC.pm
lib/Crypt/PK/RSA.pm
lib/Crypt/PRNG.pm
lib/Crypt/PRNG/ChaCha20.pm
lib/Crypt/PRNG/Fortuna.pm
lib/Crypt/PRNG/RC4.pm
lib/Crypt/PRNG/Sober128.pm
lib/Crypt/PRNG/Yarrow.pm
lib/Crypt/Stream/ChaCha.pm
lib/Crypt/Stream/Rabbit.pm
lib/Crypt/Stream/RC4.pm
lib/Crypt/Stream/Salsa20.pm
lib/Crypt/Stream/Sober128.pm
lib/Crypt/Stream/Sosemanuk.pm
lib/CryptX.pm
lib/Math/BigInt/LTM.pm
LICENSE
Makefile.PL
MANIFEST This list of files
META.json
META.yml
ppport.h
README.md
src/ltc/ciphers/aes/aes.c
src/ltc/ciphers/aes/aes_tab.c
src/ltc/ciphers/anubis.c
src/ltc/ciphers/blowfish.c
src/ltc/ciphers/camellia.c
src/ltc/ciphers/cast5.c
src/ltc/ciphers/des.c
src/ltc/ciphers/idea.c
src/ltc/ciphers/kasumi.c
src/ltc/ciphers/khazad.c
src/ltc/ciphers/kseed.c
src/ltc/ciphers/multi2.c
src/ltc/ciphers/noekeon.c
src/ltc/ciphers/rc2.c
src/ltc/ciphers/rc5.c
src/ltc/ciphers/rc6.c
src/ltc/ciphers/safer/safer.c
src/ltc/ciphers/safer/safer_tab.c
src/ltc/ciphers/safer/saferp.c
src/ltc/ciphers/serpent.c
src/ltc/ciphers/skipjack.c
src/ltc/ciphers/twofish/twofish.c
src/ltc/ciphers/twofish/twofish_tab.c
src/ltc/ciphers/xtea.c
src/ltc/encauth/ccm/ccm_add_aad.c
src/ltc/encauth/ccm/ccm_add_nonce.c
src/ltc/encauth/ccm/ccm_done.c
src/ltc/encauth/ccm/ccm_init.c
src/ltc/encauth/ccm/ccm_memory.c
src/ltc/encauth/ccm/ccm_process.c
src/ltc/encauth/ccm/ccm_reset.c
src/ltc/encauth/chachapoly/chacha20poly1305_add_aad.c
src/ltc/encauth/chachapoly/chacha20poly1305_decrypt.c
src/ltc/encauth/chachapoly/chacha20poly1305_done.c
src/ltc/encauth/chachapoly/chacha20poly1305_encrypt.c
src/ltc/encauth/chachapoly/chacha20poly1305_init.c
src/ltc/encauth/chachapoly/chacha20poly1305_memory.c
src/ltc/encauth/chachapoly/chacha20poly1305_setiv.c
src/ltc/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.c
src/ltc/encauth/eax/eax_addheader.c
src/ltc/encauth/eax/eax_decrypt.c
src/ltc/encauth/eax/eax_decrypt_verify_memory.c
src/ltc/encauth/eax/eax_done.c
src/ltc/encauth/eax/eax_encrypt.c
src/ltc/encauth/eax/eax_encrypt_authenticate_memory.c
src/ltc/encauth/eax/eax_init.c
src/ltc/encauth/gcm/gcm_add_aad.c
src/ltc/encauth/gcm/gcm_add_iv.c
src/ltc/encauth/gcm/gcm_done.c
src/ltc/encauth/gcm/gcm_gf_mult.c
src/ltc/encauth/gcm/gcm_init.c
src/ltc/encauth/gcm/gcm_memory.c
src/ltc/encauth/gcm/gcm_mult_h.c
src/ltc/encauth/gcm/gcm_process.c
src/ltc/encauth/gcm/gcm_reset.c
src/ltc/encauth/ocb3/ocb3_add_aad.c
src/ltc/encauth/ocb3/ocb3_decrypt.c
src/ltc/encauth/ocb3/ocb3_decrypt_last.c
src/ltc/encauth/ocb3/ocb3_decrypt_verify_memory.c
src/ltc/encauth/ocb3/ocb3_done.c
src/ltc/encauth/ocb3/ocb3_encrypt.c
src/ltc/encauth/ocb3/ocb3_encrypt_authenticate_memory.c
src/ltc/encauth/ocb3/ocb3_encrypt_last.c
src/ltc/encauth/ocb3/ocb3_init.c
src/ltc/encauth/ocb3/ocb3_int_ntz.c
src/ltc/encauth/ocb3/ocb3_int_xor_blocks.c
src/ltc/hashes/blake2b.c
src/ltc/hashes/blake2s.c
src/ltc/hashes/chc/chc.c
src/ltc/hashes/helper/hash_file.c
src/ltc/hashes/helper/hash_filehandle.c
src/ltc/hashes/helper/hash_memory.c
src/ltc/hashes/helper/hash_memory_multi.c
src/ltc/hashes/md2.c
src/ltc/hashes/md4.c
src/ltc/hashes/md5.c
src/ltc/hashes/rmd128.c
src/ltc/hashes/rmd160.c
src/ltc/hashes/rmd256.c
src/ltc/hashes/rmd320.c
src/ltc/hashes/sha1.c
src/ltc/hashes/sha2/sha224.c
src/ltc/hashes/sha2/sha256.c
src/ltc/hashes/sha2/sha384.c
src/ltc/hashes/sha2/sha512.c
src/ltc/hashes/sha2/sha512_224.c
src/ltc/hashes/sha2/sha512_256.c
src/ltc/hashes/sha3.c
src/ltc/hashes/sha3_test.c
src/ltc/hashes/tiger.c
src/ltc/hashes/whirl/whirl.c
src/ltc/hashes/whirl/whirltab.c
src/ltc/headers/tomcrypt.h
src/ltc/headers/tomcrypt_argchk.h
src/ltc/headers/tomcrypt_cfg.h
src/ltc/headers/tomcrypt_cipher.h
src/ltc/headers/tomcrypt_custom.h
src/ltc/headers/tomcrypt_hash.h
src/ltc/headers/tomcrypt_mac.h
src/ltc/headers/tomcrypt_macros.h
src/ltc/headers/tomcrypt_math.h
src/ltc/headers/tomcrypt_misc.h
src/ltc/headers/tomcrypt_pk.h
src/ltc/headers/tomcrypt_pkcs.h
src/ltc/headers/tomcrypt_prng.h
src/ltc/mac/blake2/blake2bmac.c
src/ltc/mac/blake2/blake2bmac_file.c
src/ltc/mac/blake2/blake2bmac_memory.c
src/ltc/mac/blake2/blake2bmac_memory_multi.c
src/ltc/mac/blake2/blake2smac.c
src/ltc/mac/blake2/blake2smac_file.c
src/ltc/mac/blake2/blake2smac_memory.c
src/ltc/mac/blake2/blake2smac_memory_multi.c
src/ltc/mac/f9/f9_done.c
src/ltc/mac/f9/f9_file.c
src/ltc/mac/f9/f9_init.c
src/ltc/mac/f9/f9_memory.c
src/ltc/mac/f9/f9_memory_multi.c
src/ltc/mac/f9/f9_process.c
src/ltc/mac/hmac/hmac_done.c
src/ltc/mac/hmac/hmac_file.c
src/ltc/mac/hmac/hmac_init.c
src/ltc/mac/hmac/hmac_memory.c
src/ltc/mac/hmac/hmac_memory_multi.c
src/ltc/mac/hmac/hmac_process.c
src/ltc/mac/omac/omac_done.c
src/ltc/mac/omac/omac_file.c
src/ltc/mac/omac/omac_init.c
src/ltc/mac/omac/omac_memory.c
src/ltc/mac/omac/omac_memory_multi.c
src/ltc/mac/omac/omac_process.c
src/ltc/mac/pelican/pelican.c
src/ltc/mac/pelican/pelican_memory.c
src/ltc/mac/pmac/pmac_done.c
src/ltc/mac/pmac/pmac_file.c
src/ltc/mac/pmac/pmac_init.c
src/ltc/mac/pmac/pmac_memory.c
src/ltc/mac/pmac/pmac_memory_multi.c
src/ltc/mac/pmac/pmac_ntz.c
src/ltc/mac/pmac/pmac_process.c
src/ltc/mac/pmac/pmac_shift_xor.c
src/ltc/mac/poly1305/poly1305.c
src/ltc/mac/poly1305/poly1305_file.c
src/ltc/mac/poly1305/poly1305_memory.c
src/ltc/mac/poly1305/poly1305_memory_multi.c
src/ltc/mac/xcbc/xcbc_done.c
src/ltc/mac/xcbc/xcbc_file.c
src/ltc/mac/xcbc/xcbc_init.c
src/ltc/mac/xcbc/xcbc_memory.c
src/ltc/mac/xcbc/xcbc_memory_multi.c
src/ltc/mac/xcbc/xcbc_process.c
src/ltc/math/fp/ltc_ecc_fp_mulmod.c
src/ltc/math/ltm_desc.c
src/ltc/math/multi.c
src/ltc/math/radix_to_bin.c
src/ltc/math/rand_bn.c
src/ltc/math/rand_prime.c
src/ltc/math/tfm_desc.c
src/ltc/misc/adler32.c
src/ltc/misc/base32/base32_decode.c
src/ltc/misc/base32/base32_encode.c
src/ltc/misc/base64/base64_decode.c
src/ltc/misc/base64/base64_encode.c
src/ltc/misc/burn_stack.c
src/ltc/misc/compare_testvector.c
src/ltc/misc/copy_or_zeromem.c
src/ltc/misc/crc32.c
src/ltc/misc/crypt/crypt.c
src/ltc/misc/crypt/crypt_argchk.c
src/ltc/misc/crypt/crypt_cipher_descriptor.c
src/ltc/misc/crypt/crypt_cipher_is_valid.c
src/ltc/misc/crypt/crypt_constants.c
src/ltc/misc/crypt/crypt_find_cipher.c
src/ltc/misc/crypt/crypt_find_cipher_any.c
src/ltc/misc/crypt/crypt_find_cipher_id.c
src/ltc/misc/crypt/crypt_find_hash.c
src/ltc/misc/crypt/crypt_find_hash_any.c
src/ltc/misc/crypt/crypt_find_hash_id.c
src/ltc/misc/crypt/crypt_find_hash_oid.c
src/ltc/misc/crypt/crypt_find_prng.c
src/ltc/misc/crypt/crypt_fsa.c
src/ltc/misc/crypt/crypt_hash_descriptor.c
src/ltc/misc/crypt/crypt_hash_is_valid.c
src/ltc/misc/crypt/crypt_inits.c
src/ltc/misc/crypt/crypt_ltc_mp_descriptor.c
src/ltc/misc/crypt/crypt_prng_descriptor.c
src/ltc/misc/crypt/crypt_prng_is_valid.c
src/ltc/misc/crypt/crypt_prng_rng_descriptor.c
src/ltc/misc/crypt/crypt_register_all_ciphers.c
src/ltc/misc/crypt/crypt_register_all_hashes.c
src/ltc/misc/crypt/crypt_register_all_prngs.c
src/ltc/misc/crypt/crypt_register_cipher.c
src/ltc/misc/crypt/crypt_register_hash.c
src/ltc/misc/crypt/crypt_register_prng.c
src/ltc/misc/crypt/crypt_sizes.c
src/ltc/misc/crypt/crypt_unregister_cipher.c
src/ltc/misc/crypt/crypt_unregister_hash.c
src/ltc/misc/crypt/crypt_unregister_prng.c
src/ltc/misc/error_to_string.c
src/ltc/misc/hkdf/hkdf.c
src/ltc/misc/mem_neq.c
src/ltc/misc/pk_get_oid.c
src/ltc/misc/pkcs5/pkcs_5_1.c
src/ltc/misc/pkcs5/pkcs_5_2.c
src/ltc/misc/zeromem.c
src/ltc/modes/cbc/cbc_decrypt.c
src/ltc/modes/cbc/cbc_done.c
src/ltc/modes/cbc/cbc_encrypt.c
src/ltc/modes/cbc/cbc_getiv.c
src/ltc/modes/cbc/cbc_setiv.c
src/ltc/modes/cbc/cbc_start.c
src/ltc/modes/cfb/cfb_decrypt.c
src/ltc/modes/cfb/cfb_done.c
src/ltc/modes/cfb/cfb_encrypt.c
src/ltc/modes/cfb/cfb_getiv.c
src/ltc/modes/cfb/cfb_setiv.c
src/ltc/modes/cfb/cfb_start.c
src/ltc/modes/ctr/ctr_decrypt.c
src/ltc/modes/ctr/ctr_done.c
src/ltc/modes/ctr/ctr_encrypt.c
src/ltc/modes/ctr/ctr_getiv.c
src/ltc/modes/ctr/ctr_setiv.c
src/ltc/modes/ctr/ctr_start.c
src/ltc/modes/ecb/ecb_decrypt.c
src/ltc/modes/ecb/ecb_done.c
src/ltc/modes/ecb/ecb_encrypt.c
src/ltc/modes/ecb/ecb_start.c
src/ltc/modes/ofb/ofb_decrypt.c
src/ltc/modes/ofb/ofb_done.c
src/ltc/modes/ofb/ofb_encrypt.c
src/ltc/modes/ofb/ofb_getiv.c
src/ltc/modes/ofb/ofb_setiv.c
src/ltc/modes/ofb/ofb_start.c
src/ltc/pk/asn1/der/bit/der_decode_bit_string.c
src/ltc/pk/asn1/der/bit/der_decode_raw_bit_string.c
src/ltc/pk/asn1/der/bit/der_encode_bit_string.c
src/ltc/pk/asn1/der/bit/der_encode_raw_bit_string.c
src/ltc/pk/asn1/der/bit/der_length_bit_string.c
src/ltc/pk/asn1/der/boolean/der_decode_boolean.c
src/ltc/pk/asn1/der/boolean/der_encode_boolean.c
src/ltc/pk/asn1/der/boolean/der_length_boolean.c
src/ltc/pk/asn1/der/choice/der_decode_choice.c
src/ltc/pk/asn1/der/custom_type/der_decode_custom_type.c
src/ltc/pk/asn1/der/custom_type/der_encode_custom_type.c
src/ltc/pk/asn1/der/custom_type/der_length_custom_type.c
src/ltc/pk/asn1/der/general/der_asn1_maps.c
src/ltc/pk/asn1/der/general/der_decode_asn1_identifier.c
src/ltc/pk/asn1/der/general/der_decode_asn1_length.c
src/ltc/pk/asn1/der/general/der_encode_asn1_identifier.c
src/ltc/pk/asn1/der/general/der_encode_asn1_length.c
src/ltc/pk/asn1/der/general/der_length_asn1_identifier.c
src/ltc/pk/asn1/der/general/der_length_asn1_length.c
src/ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c
src/ltc/pk/asn1/der/generalizedtime/der_encode_generalizedtime.c
src/ltc/pk/asn1/der/generalizedtime/der_length_generalizedtime.c
src/ltc/pk/asn1/der/ia5/der_decode_ia5_string.c
src/ltc/pk/asn1/der/ia5/der_encode_ia5_string.c
src/ltc/pk/asn1/der/ia5/der_length_ia5_string.c
src/ltc/pk/asn1/der/integer/der_decode_integer.c
src/ltc/pk/asn1/der/integer/der_encode_integer.c
src/ltc/pk/asn1/der/integer/der_length_integer.c
src/ltc/pk/asn1/der/object_identifier/der_decode_object_identifier.c
src/ltc/pk/asn1/der/object_identifier/der_encode_object_identifier.c
src/ltc/pk/asn1/der/object_identifier/der_length_object_identifier.c
src/ltc/pk/asn1/der/octet/der_decode_octet_string.c
src/ltc/pk/asn1/der/octet/der_encode_octet_string.c
src/ltc/pk/asn1/der/octet/der_length_octet_string.c
src/ltc/pk/asn1/der/printable_string/der_decode_printable_string.c
src/ltc/pk/asn1/der/printable_string/der_encode_printable_string.c
src/ltc/pk/asn1/der/printable_string/der_length_printable_string.c
src/ltc/pk/asn1/der/sequence/der_decode_sequence_ex.c
src/ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.c
src/ltc/pk/asn1/der/sequence/der_decode_sequence_multi.c
src/ltc/pk/asn1/der/sequence/der_encode_sequence_ex.c
src/ltc/pk/asn1/der/sequence/der_encode_sequence_multi.c
src/ltc/pk/asn1/der/sequence/der_length_sequence.c
src/ltc/pk/asn1/der/sequence/der_sequence_free.c
src/ltc/pk/asn1/der/sequence/der_sequence_shrink.c
src/ltc/pk/asn1/der/set/der_encode_set.c
src/ltc/pk/asn1/der/set/der_encode_setof.c
src/ltc/pk/asn1/der/short_integer/der_decode_short_integer.c
src/ltc/pk/asn1/der/short_integer/der_encode_short_integer.c
src/ltc/pk/asn1/der/short_integer/der_length_short_integer.c
src/ltc/pk/asn1/der/teletex_string/der_decode_teletex_string.c
src/ltc/pk/asn1/der/teletex_string/der_length_teletex_string.c
src/ltc/pk/asn1/der/utctime/der_decode_utctime.c
src/ltc/pk/asn1/der/utctime/der_encode_utctime.c
src/ltc/pk/asn1/der/utctime/der_length_utctime.c
src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c
src/ltc/pk/asn1/der/utf8/der_encode_utf8_string.c
src/ltc/pk/asn1/der/utf8/der_length_utf8_string.c
src/ltc/pk/asn1/x509/x509_decode_subject_public_key_info.c
src/ltc/pk/asn1/x509/x509_encode_subject_public_key_info.c
src/ltc/pk/dh/dh.c
src/ltc/pk/dh/dh_check_pubkey.c
src/ltc/pk/dh/dh_export.c
src/ltc/pk/dh/dh_export_key.c
src/ltc/pk/dh/dh_free.c
src/ltc/pk/dh/dh_generate_key.c
src/ltc/pk/dh/dh_import.c
src/ltc/pk/dh/dh_set.c
src/ltc/pk/dh/dh_set_pg_dhparam.c
src/ltc/pk/dh/dh_shared_secret.c
src/ltc/pk/dsa/dsa_decrypt_key.c
src/ltc/pk/dsa/dsa_encrypt_key.c
src/ltc/pk/dsa/dsa_export.c
src/ltc/pk/dsa/dsa_free.c
src/ltc/pk/dsa/dsa_generate_key.c
src/ltc/pk/dsa/dsa_generate_pqg.c
src/ltc/pk/dsa/dsa_import.c
src/ltc/pk/dsa/dsa_make_key.c
src/ltc/pk/dsa/dsa_set.c
src/ltc/pk/dsa/dsa_set_pqg_dsaparam.c
src/ltc/pk/dsa/dsa_shared_secret.c
src/ltc/pk/dsa/dsa_sign_hash.c
src/ltc/pk/dsa/dsa_verify_hash.c
src/ltc/pk/dsa/dsa_verify_key.c
src/ltc/pk/ecc/ecc.c
src/ltc/pk/ecc/ecc_ansi_x963_export.c
src/ltc/pk/ecc/ecc_ansi_x963_import.c
src/ltc/pk/ecc/ecc_decrypt_key.c
src/ltc/pk/ecc/ecc_encrypt_key.c
src/ltc/pk/ecc/ecc_export.c
src/ltc/pk/ecc/ecc_export_openssl.c
src/ltc/pk/ecc/ecc_free.c
src/ltc/pk/ecc/ecc_get_key.c
src/ltc/pk/ecc/ecc_get_set.c
src/ltc/pk/ecc/ecc_get_size.c
src/ltc/pk/ecc/ecc_import.c
src/ltc/pk/ecc/ecc_import_openssl.c
src/ltc/pk/ecc/ecc_import_pkcs8.c
src/ltc/pk/ecc/ecc_import_x509.c
src/ltc/pk/ecc/ecc_make_key.c
src/ltc/pk/ecc/ecc_set_dp.c
src/ltc/pk/ecc/ecc_set_dp_internal.c
src/ltc/pk/ecc/ecc_set_key.c
src/ltc/pk/ecc/ecc_shared_secret.c
src/ltc/pk/ecc/ecc_sign_hash.c
src/ltc/pk/ecc/ecc_sizes.c
src/ltc/pk/ecc/ecc_verify_hash.c
src/ltc/pk/ecc/ltc_ecc_export_point.c
src/ltc/pk/ecc/ltc_ecc_import_point.c
src/ltc/pk/ecc/ltc_ecc_is_point.c
src/ltc/pk/ecc/ltc_ecc_is_point_at_infinity.c
src/ltc/pk/ecc/ltc_ecc_map.c
src/ltc/pk/ecc/ltc_ecc_mul2add.c
src/ltc/pk/ecc/ltc_ecc_mulmod.c
src/ltc/pk/ecc/ltc_ecc_mulmod_timing.c
src/ltc/pk/ecc/ltc_ecc_points.c
src/ltc/pk/ecc/ltc_ecc_projective_add_point.c
src/ltc/pk/ecc/ltc_ecc_projective_dbl_point.c
src/ltc/pk/ecc/ltc_ecc_verify_key.c
src/ltc/pk/pkcs1/pkcs_1_i2osp.c
src/ltc/pk/pkcs1/pkcs_1_mgf1.c
src/ltc/pk/pkcs1/pkcs_1_oaep_decode.c
src/ltc/pk/pkcs1/pkcs_1_oaep_encode.c
src/ltc/pk/pkcs1/pkcs_1_os2ip.c
src/ltc/pk/pkcs1/pkcs_1_pss_decode.c
src/ltc/pk/pkcs1/pkcs_1_pss_encode.c
src/ltc/pk/pkcs1/pkcs_1_v1_5_decode.c
src/ltc/pk/pkcs1/pkcs_1_v1_5_encode.c
src/ltc/pk/rsa/rsa_decrypt_key.c
src/ltc/pk/rsa/rsa_encrypt_key.c
src/ltc/pk/rsa/rsa_export.c
src/ltc/pk/rsa/rsa_exptmod.c
src/ltc/pk/rsa/rsa_free.c
src/ltc/pk/rsa/rsa_get_size.c
src/ltc/pk/rsa/rsa_import.c
src/ltc/pk/rsa/rsa_import_pkcs8.c
src/ltc/pk/rsa/rsa_import_x509.c
src/ltc/pk/rsa/rsa_make_key.c
src/ltc/pk/rsa/rsa_set.c
src/ltc/pk/rsa/rsa_sign_hash.c
src/ltc/pk/rsa/rsa_sign_saltlen_get.c
src/ltc/pk/rsa/rsa_verify_hash.c
src/ltc/prngs/chacha20.c
src/ltc/prngs/fortuna.c
src/ltc/prngs/rc4.c
src/ltc/prngs/rng_get_bytes.c
src/ltc/prngs/rng_make_prng.c
src/ltc/prngs/sober128.c
src/ltc/prngs/sprng.c
src/ltc/prngs/yarrow.c
src/ltc/stream/chacha/chacha_crypt.c
src/ltc/stream/chacha/chacha_done.c
src/ltc/stream/chacha/chacha_ivctr32.c
src/ltc/stream/chacha/chacha_ivctr64.c
src/ltc/stream/chacha/chacha_keystream.c
src/ltc/stream/chacha/chacha_setup.c
src/ltc/stream/rabbit/rabbit.c
src/ltc/stream/rc4/rc4_stream.c
src/ltc/stream/salsa20/salsa20_crypt.c
src/ltc/stream/salsa20/salsa20_done.c
src/ltc/stream/salsa20/salsa20_ivctr64.c
src/ltc/stream/salsa20/salsa20_keystream.c
src/ltc/stream/salsa20/salsa20_setup.c
src/ltc/stream/sober128/sober128_stream.c
src/ltc/stream/sober128/sober128tab.c
src/ltc/stream/sosemanuk/sosemanuk.c
src/ltm/bn_error.c
src/ltm/bn_fast_mp_invmod.c
src/ltm/bn_fast_mp_montgomery_reduce.c
src/ltm/bn_fast_s_mp_mul_digs.c
src/ltm/bn_fast_s_mp_mul_high_digs.c
src/ltm/bn_fast_s_mp_sqr.c
src/ltm/bn_mp_2expt.c
src/ltm/bn_mp_abs.c
src/ltm/bn_mp_add.c
src/ltm/bn_mp_add_d.c
src/ltm/bn_mp_addmod.c
src/ltm/bn_mp_and.c
src/ltm/bn_mp_clamp.c
src/ltm/bn_mp_clear.c
src/ltm/bn_mp_clear_multi.c
src/ltm/bn_mp_cmp.c
src/ltm/bn_mp_cmp_d.c
src/ltm/bn_mp_cmp_mag.c
src/ltm/bn_mp_cnt_lsb.c
src/ltm/bn_mp_copy.c
src/ltm/bn_mp_count_bits.c
src/ltm/bn_mp_div.c
src/ltm/bn_mp_div_2.c
src/ltm/bn_mp_div_2d.c
src/ltm/bn_mp_div_3.c
src/ltm/bn_mp_div_d.c
src/ltm/bn_mp_dr_is_modulus.c
src/ltm/bn_mp_dr_reduce.c
src/ltm/bn_mp_dr_setup.c
src/ltm/bn_mp_exch.c
src/ltm/bn_mp_export.c
src/ltm/bn_mp_expt_d.c
src/ltm/bn_mp_expt_d_ex.c
src/ltm/bn_mp_exptmod.c
src/ltm/bn_mp_exptmod_fast.c
src/ltm/bn_mp_exteuclid.c
src/ltm/bn_mp_fread.c
src/ltm/bn_mp_fwrite.c
src/ltm/bn_mp_gcd.c
src/ltm/bn_mp_get_int.c
src/ltm/bn_mp_get_long.c
src/ltm/bn_mp_get_long_long.c
src/ltm/bn_mp_grow.c
src/ltm/bn_mp_import.c
src/ltm/bn_mp_init.c
src/ltm/bn_mp_init_copy.c
src/ltm/bn_mp_init_multi.c
src/ltm/bn_mp_init_set.c
src/ltm/bn_mp_init_set_int.c
src/ltm/bn_mp_init_size.c
src/ltm/bn_mp_invmod.c
src/ltm/bn_mp_invmod_slow.c
src/ltm/bn_mp_is_square.c
src/ltm/bn_mp_jacobi.c
src/ltm/bn_mp_karatsuba_mul.c
src/ltm/bn_mp_karatsuba_sqr.c
src/ltm/bn_mp_lcm.c
src/ltm/bn_mp_lshd.c
src/ltm/bn_mp_mod.c
src/ltm/bn_mp_mod_2d.c
src/ltm/bn_mp_mod_d.c
src/ltm/bn_mp_montgomery_calc_normalization.c
src/ltm/bn_mp_montgomery_reduce.c
src/ltm/bn_mp_montgomery_setup.c
src/ltm/bn_mp_mul.c
src/ltm/bn_mp_mul_2.c
src/ltm/bn_mp_mul_2d.c
src/ltm/bn_mp_mul_d.c
src/ltm/bn_mp_mulmod.c
src/ltm/bn_mp_n_root.c
src/ltm/bn_mp_n_root_ex.c
src/ltm/bn_mp_neg.c
src/ltm/bn_mp_or.c
src/ltm/bn_mp_prime_fermat.c
src/ltm/bn_mp_prime_is_divisible.c
src/ltm/bn_mp_prime_is_prime.c
src/ltm/bn_mp_prime_miller_rabin.c
src/ltm/bn_mp_prime_next_prime.c
src/ltm/bn_mp_prime_rabin_miller_trials.c
src/ltm/bn_mp_prime_random_ex.c
src/ltm/bn_mp_radix_size.c
src/ltm/bn_mp_radix_smap.c
src/ltm/bn_mp_rand.c
src/ltm/bn_mp_read_radix.c
src/ltm/bn_mp_read_signed_bin.c
src/ltm/bn_mp_read_unsigned_bin.c
src/ltm/bn_mp_reduce.c
src/ltm/bn_mp_reduce_2k.c
src/ltm/bn_mp_reduce_2k_l.c
src/ltm/bn_mp_reduce_2k_setup.c
src/ltm/bn_mp_reduce_2k_setup_l.c
src/ltm/bn_mp_reduce_is_2k.c
src/ltm/bn_mp_reduce_is_2k_l.c
src/ltm/bn_mp_reduce_setup.c
src/ltm/bn_mp_rshd.c
src/ltm/bn_mp_set.c
src/ltm/bn_mp_set_int.c
src/ltm/bn_mp_set_long.c
src/ltm/bn_mp_set_long_long.c
src/ltm/bn_mp_shrink.c
src/ltm/bn_mp_signed_bin_size.c
src/ltm/bn_mp_sqr.c
src/ltm/bn_mp_sqrmod.c
src/ltm/bn_mp_sqrt.c
src/ltm/bn_mp_sqrtmod_prime.c
src/ltm/bn_mp_sub.c
src/ltm/bn_mp_sub_d.c
src/ltm/bn_mp_submod.c
src/ltm/bn_mp_to_signed_bin.c
src/ltm/bn_mp_to_signed_bin_n.c
src/ltm/bn_mp_to_unsigned_bin.c
src/ltm/bn_mp_to_unsigned_bin_n.c
src/ltm/bn_mp_toom_mul.c
src/ltm/bn_mp_toom_sqr.c
src/ltm/bn_mp_toradix.c
src/ltm/bn_mp_toradix_n.c
src/ltm/bn_mp_unsigned_bin_size.c
src/ltm/bn_mp_xor.c
src/ltm/bn_mp_zero.c
src/ltm/bn_prime_tab.c
src/ltm/bn_reverse.c
src/ltm/bn_s_mp_add.c
src/ltm/bn_s_mp_exptmod.c
src/ltm/bn_s_mp_mul_digs.c
src/ltm/bn_s_mp_mul_high_digs.c
src/ltm/bn_s_mp_sqr.c
src/ltm/bn_s_mp_sub.c
src/ltm/bncore.c
src/ltm/tommath.h
src/ltm/tommath_class.h
src/ltm/tommath_private.h
src/ltm/tommath_superclass.h
src/Makefile
src/Makefile.nmake
t/001_compile.t
t/002_all_pm.t
t/003_all_pm_pod.t
t/004_all_pm_pod_spelling.t
t/005_all_pm_pod_coverage.t
t/auth_enc_ccm.t
t/auth_enc_ccm_test_vector_ltc.t
t/auth_enc_chacha20poly1305.t
t/auth_enc_eax.t
t/auth_enc_eax_test_vector_ltc.t
t/auth_enc_gcm.t
t/auth_enc_gcm_test_vector_ltc.t
t/auth_enc_ocb.t
t/auth_enc_ocb_test_vectors_ietf.t
t/checksum.t
t/cipher_aes.t
t/cipher_aes_test_vectors_bc.t
t/cipher_anubis.t
t/cipher_blowfish.t
t/cipher_camellia.t
t/cipher_cast5.t
t/cipher_des.t
t/cipher_des_ede.t
t/cipher_idea.t
t/cipher_idea_compat.t
t/cipher_kasumi.t
t/cipher_khazad.t
t/cipher_multi2.t
t/cipher_multi2_rounds.t
t/cipher_noekeon.t
t/cipher_rc2.t
t/cipher_rc5.t
t/cipher_rc6.t
t/cipher_safer_k128.t
t/cipher_safer_k64.t
t/cipher_safer_sk128.t
t/cipher_safer_sk64.t
t/cipher_saferp.t
t/cipher_seed.t
t/cipher_seed_test_vectors_bc.t
t/cipher_serpent.t
t/cipher_serpent_compat.t
t/cipher_skipjack.t
t/cipher_stream.t
t/cipher_stream_rabbit.t
t/cipher_stream_salsa20.t
t/cipher_test_vectors_ltc.t
t/cipher_test_vectors_openssl.t
t/cipher_twofish.t
t/cipher_twofish_test_vectors_bc.t
t/cipher_xtea.t
t/cipher_xtea_test_vectors_bc.t
t/crypt-misc.t
t/data/binary-test.file
t/data/cryptx_priv_dh1.bin
t/data/cryptx_priv_dh2.bin
t/data/cryptx_priv_dh_pg1.bin
t/data/cryptx_priv_dh_pg2.bin
t/data/cryptx_priv_dsa1.der
t/data/cryptx_priv_dsa1.pem
t/data/cryptx_priv_dsa2.der
t/data/cryptx_priv_dsa2.pem
t/data/cryptx_priv_ecc1.der
t/data/cryptx_priv_ecc1.pem
t/data/cryptx_priv_ecc1_OLD.der
t/data/cryptx_priv_ecc1_OLD.pem
t/data/cryptx_priv_ecc2.der
t/data/cryptx_priv_ecc2.pem
t/data/cryptx_priv_ecc2_OLD.der
t/data/cryptx_priv_ecc2_OLD.pem
t/data/cryptx_priv_rsa1.der
t/data/cryptx_priv_rsa1.pem
t/data/cryptx_priv_rsa2.der
t/data/cryptx_priv_rsa2.pem
t/data/cryptx_pub_dh1.bin
t/data/cryptx_pub_dh2.bin
t/data/cryptx_pub_dh_pg1.bin
t/data/cryptx_pub_dh_pg2.bin
t/data/cryptx_pub_dsa1.der
t/data/cryptx_pub_dsa1.pem
t/data/cryptx_pub_dsa2.der
t/data/cryptx_pub_dsa2.pem
t/data/cryptx_pub_ecc1.der
t/data/cryptx_pub_ecc1.pem
t/data/cryptx_pub_ecc1_OLD.der
t/data/cryptx_pub_ecc1_OLD.pem
t/data/cryptx_pub_ecc2.der
t/data/cryptx_pub_ecc2.pem
t/data/cryptx_pub_ecc2_OLD.der
t/data/cryptx_pub_ecc2_OLD.pem
t/data/cryptx_pub_rsa1.der
t/data/cryptx_pub_rsa1.pem
t/data/cryptx_pub_rsa2.der
t/data/cryptx_pub_rsa2.pem
t/data/dsa-aes128.pem
t/data/dsa-aes192.pem
t/data/dsa-aes256.pem
t/data/dsa-camellia128.pem
t/data/dsa-camellia192.pem
t/data/dsa-camellia256.pem
t/data/dsa-des.pem
t/data/dsa-des3.pem
t/data/dsa-param.pem
t/data/dsa-seed.pem
t/data/ec-aes128.pem
t/data/ec-aes192.pem
t/data/ec-aes256.pem
t/data/ec-camellia128.pem
t/data/ec-camellia192.pem
t/data/ec-camellia256.pem
t/data/ec-des.pem
t/data/ec-des3.pem
t/data/ec-seed.pem
t/data/jwk_ec-priv1.json
t/data/jwk_ec-pub.json
t/data/jwk_ec-pub1.json
t/data/jwk_rsa-priv.json
t/data/jwk_rsa-priv1.json
t/data/jwk_rsa-pub1.json
t/data/openssl_dsa1.der
t/data/openssl_dsa1.pem
t/data/openssl_dsa2.der
t/data/openssl_dsa2.pem
t/data/openssl_ec-short.der
t/data/openssl_ec-short.pem
t/data/openssl_ec-short.pub.der
t/data/openssl_ec-short.pub.pem
t/data/openssl_ec1.key.pem
t/data/openssl_ec1.pri.der
t/data/openssl_ec1.pri.pem
t/data/openssl_ec1.pric.der
t/data/openssl_ec1.pric.pem
t/data/openssl_ec1.pub.der
t/data/openssl_ec1.pub.pem
t/data/openssl_ec1.pubc.der
t/data/openssl_ec1.pubc.pem
t/data/openssl_rsa-x509.der
t/data/openssl_rsa-x509.pem
t/data/openssl_rsa1.der
t/data/openssl_rsa1.pem
t/data/openssl_rsa1.pubonly.der
t/data/openssl_rsa1.pubonly.pem
t/data/openssl_rsa2.der
t/data/openssl_rsa2.pem
t/data/openssl_rsa2.pubonly.der
t/data/openssl_rsa2.pubonly.pem
t/data/pkcs8.ec-priv-nopass.der
t/data/pkcs8.ec-priv-nopass.pem
t/data/pkcs8.ec-priv-pass.der
t/data/pkcs8.ec-priv-pass.pem
t/data/pkcs8.ec-short-priv-nopass.der
t/data/pkcs8.ec-short-priv-nopass.pem
t/data/pkcs8.ec-short-priv-pass.der
t/data/pkcs8.ec-short-priv-pass.pem
t/data/pkcs8.rsa-priv-nopass.der
t/data/pkcs8.rsa-priv-nopass.pem
t/data/pkcs8.rsa-priv-pass.der
t/data/pkcs8.rsa-priv-pass.pem
t/data/rsa-aes128.pem
t/data/rsa-aes192.pem
t/data/rsa-aes256.pem
t/data/rsa-camellia128.pem
t/data/rsa-camellia192.pem
t/data/rsa-camellia256.pem
t/data/rsa-des.pem
t/data/rsa-des3.pem
t/data/rsa-seed.pem
t/data/ssh/ssh_dsa_1024
t/data/ssh/ssh_dsa_1024.pub
t/data/ssh/ssh_dsa_1024.pub.pkcs8
t/data/ssh/ssh_dsa_1024.pub.rfc4716
t/data/ssh/ssh_ecdsa_256
t/data/ssh/ssh_ecdsa_256.pub
t/data/ssh/ssh_ecdsa_256.pub.pkcs8
t/data/ssh/ssh_ecdsa_256.pub.rfc4716
t/data/ssh/ssh_ecdsa_384
t/data/ssh/ssh_ecdsa_384.pub
t/data/ssh/ssh_ecdsa_384.pub.pkcs8
t/data/ssh/ssh_ecdsa_384.pub.rfc4716
t/data/ssh/ssh_ecdsa_521
t/data/ssh/ssh_ecdsa_521.pub
t/data/ssh/ssh_ecdsa_521.pub.pkcs8
t/data/ssh/ssh_ecdsa_521.pub.rfc4716
t/data/ssh/ssh_rsa_1024
t/data/ssh/ssh_rsa_1024.pub
t/data/ssh/ssh_rsa_1024.pub.pem
t/data/ssh/ssh_rsa_1024.pub.pkcs8
t/data/ssh/ssh_rsa_1024.pub.rfc4716
t/data/ssh/ssh_rsa_1024_passwd
t/data/ssh/ssh_rsa_1536
t/data/ssh/ssh_rsa_1536.pub
t/data/ssh/ssh_rsa_1536.pub.pem
t/data/ssh/ssh_rsa_1536.pub.pkcs8
t/data/ssh/ssh_rsa_1536.pub.rfc4716
t/data/ssh/ssh_rsa_1536_passwd
t/data/ssh/ssh_rsa_2048
t/data/ssh/ssh_rsa_2048.pub
t/data/ssh/ssh_rsa_2048.pub.pem
t/data/ssh/ssh_rsa_2048.pub.pkcs8
t/data/ssh/ssh_rsa_2048.pub.rfc4716
t/data/ssh/ssh_rsa_2048_passwd
t/data/ssh/ssh_rsa_4096
t/data/ssh/ssh_rsa_4096.pub
t/data/ssh/ssh_rsa_4096.pub.pem
t/data/ssh/ssh_rsa_4096.pub.pkcs8
t/data/ssh/ssh_rsa_4096.pub.rfc4716
t/data/ssh/ssh_rsa_4096_passwd
t/data/ssh/ssh_rsa_768
t/data/ssh/ssh_rsa_768.pub
t/data/ssh/ssh_rsa_768.pub.pem
t/data/ssh/ssh_rsa_768.pub.pkcs8
t/data/ssh/ssh_rsa_768.pub.rfc4716
t/data/ssh/ssh_rsa_768_passwd
t/data/ssh/ssh_rsa_8192
t/data/ssh/ssh_rsa_8192.pub
t/data/ssh/ssh_rsa_8192.pub.pem
t/data/ssh/ssh_rsa_8192.pub.pkcs8
t/data/ssh/ssh_rsa_8192.pub.rfc4716
t/data/ssh/ssh_rsa_8192_passwd
t/data/text-CR.file
t/data/text-CRLF.file
t/data/text-LF.file
t/digest_blake2b_160.t
t/digest_blake2b_256.t
t/digest_blake2b_384.t
t/digest_blake2b_512.t
t/digest_blake2s_128.t
t/digest_blake2s_160.t
t/digest_blake2s_224.t
t/digest_blake2s_256.t
t/digest_chaes.t
t/digest_keccak224.t
t/digest_keccak256.t
t/digest_keccak384.t
t/digest_keccak512.t
t/digest_md2.t
t/digest_md4.t
t/digest_md5.t
t/digest_ripemd128.t
t/digest_ripemd160.t
t/digest_ripemd256.t
t/digest_ripemd320.t
t/digest_sha1.t
t/digest_sha224.t
t/digest_sha256.t
t/digest_sha384.t
t/digest_sha3_224.t
t/digest_sha3_256.t
t/digest_sha3_384.t
t/digest_sha3_512.t
t/digest_sha512.t
t/digest_sha512_224.t
t/digest_sha512_256.t
t/digest_shake.t
t/digest_test_vectors_ltc.t
t/digest_tiger192.t
t/digest_whirlpool.t
t/jwk.t
t/key_derivation.t
t/mac_blake2b.t
t/mac_blake2s.t
t/mac_f9.t
t/mac_hmac.t
t/mac_hmac_nist.t
t/mac_hmac_test_vectors_ltc.t
t/mac_omac.t
t/mac_omac_test_vectors_ltc.t
t/mac_pelican.t
t/mac_pmac.t
t/mac_pmac_test_vectors_ltc.t
t/mac_poly1305.t
t/mac_xcbc.t
t/mbi_ltm/bigfltpm.inc
t/mbi_ltm/bigintpm.inc
t/mbi_ltm_01load.t
t/mbi_ltm_bigfltpm.t
t/mbi_ltm_bigintg.t
t/mbi_ltm_bigintpm.t
t/mbi_ltm_biglog.t
t/mbi_ltm_bigroot.t
t/mbi_ltm_bugs.t
t/mbi_ltm_mbi-from-big-scalar.t
t/mbi_ltm_storable.t
t/mode_cbc.t
t/mode_cfb.t
t/mode_ctr.t
t/mode_ecb.t
t/mode_ofb.t
t/pk_dh.t
t/pk_dsa.t
t/pk_dsa_test_vectors_openssl.t
t/pk_ecc.t
t/pk_ecc_test_vectors_openssl.t
t/pk_enc_pem.t
t/pk_rsa.t
t/pk_rsa_test_vectors_openssl.t
t/pkcs8.t
t/prng.t
t/prng_chacha20.t
t/prng_fortuna.t
t/prng_rc4.t
t/prng_sober128.t
t/prng_yarrow.t
t/sshkey.t
t/wycheproof.t
t/wycheproof/aes_gcm_test.json
t/wycheproof/dsa_test.json
t/wycheproof/ecdh_webcrypto_test.json
t/wycheproof/ecdsa_test.json
t/wycheproof/ecdsa_webcrypto_test.json
t/wycheproof/rsa_signature_test.json
typemap

View File

@ -1,50 +0,0 @@
{
"abstract" : "Crypto toolkit",
"author" : [
"Karel Miko"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "CryptX",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"perl" : "5.006"
}
}
},
"release_status" : "unstable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/DCIT/perl-CryptX/issues"
},
"repository" : {
"url" : "https://github.com/DCIT/perl-CryptX"
}
},
"version" : "0.058_002",
"x_serialization_backend" : "JSON::PP version 2.94"
}

View File

@ -1,26 +0,0 @@
---
abstract: 'Crypto toolkit'
author:
- 'Karel Miko'
build_requires:
ExtUtils::MakeMaker: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: CryptX
no_index:
directory:
- t
- inc
requires:
perl: '5.006'
resources:
bugtracker: https://github.com/DCIT/perl-CryptX/issues
repository: https://github.com/DCIT/perl-CryptX
version: 0.058_002
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

View File

@ -1,125 +0,0 @@
use strict;
use warnings;
use ExtUtils::MakeMaker;
use Config;
my (@EUMM_INC_LIB, $myarflags, $mycflags);
if ($ENV{CRYPTX_CFLAGS} || $ENV{CRYPTX_LDFLAGS}) {
# EXPERIMENTAL: use system libraries libtomcrypt + libtommath
# e.g.
# CRYPTX_LDFLAGS='-L/usr/local/lib -ltommath -ltomcrypt' CRYPTX_CFLAGS='-DLTM_DESC -I/usr/local/include' perl Makefile.PL
print "CRYPTX_CFLAGS = $ENV{CRYPTX_CFLAGS}\n" if $ENV{CRYPTX_CFLAGS};
print "CRYPTX_LDFLAGS = $ENV{CRYPTX_LDFLAGS}\n" if $ENV{CRYPTX_LDFLAGS};
@EUMM_INC_LIB = (
INC => $ENV{CRYPTX_CFLAGS},
LIBS => [ $ENV{CRYPTX_LDFLAGS} ],
);
}
else {
# PREFERRED: use bundled libtomcrypt + libtommath (from ./src subdir)
my @myobjs = map { s|.c$|$Config{obj_ext}|; $_ } grep { $_ !~ m|^src/ltc/\.*tab\.c$| } (
glob('src/ltm/*.c'),
glob('src/ltc/*/*.c'),
glob('src/ltc/*/*/*.c'),
glob('src/ltc/*/*/*/*.c'),
glob('src/ltc/*/*/*/*/*.c'),
);
$mycflags = "$Config{ccflags} $Config{cccdlflags} $Config{optimize}";
#FIX: this is particularly useful for Debian https://github.com/DCIT/perl-CryptX/pull/39
$mycflags .= " $ENV{CFLAGS}" if $ENV{CFLAGS};
$mycflags .= " $ENV{CPPFLAGS}" if $ENV{CPPFLAGS};
#FIX: gcc with -flto is a trouble maker see https://github.com/DCIT/perl-CryptX/issues/32
$mycflags =~ s/-flto\b//g;
#FIX: avoid -Wwrite-strings -Wcast-qual -pedantic -pedantic-errors -ansi -std=c89
$mycflags =~ s/-pedantic\b//g;
$mycflags =~ s/-pedantic-errors\b//g;
$mycflags =~ s/-std=c89\b//g;
$mycflags =~ s/-ansi\b//g;
$mycflags =~ s/-Wwrite-strings\b//g;
$mycflags =~ s/-Wcast-qual\b//g;
#FIX: avoid "ar: fatal: Numeric group ID too large" see https://github.com/DCIT/perl-CryptX/issues/33
$myarflags = '$(AR_STATIC_ARGS)';
if ($^O ne 'MSWin32' && $Config{ar}) {
# for ar's "deterministic mode" we need GNU binutils 2.20+ (2009-10-16)
my $arver = `$Config{ar} --version 2>/dev/null`;
my ($maj, $min) = $arver =~ /^GNU ar [^\d]*(\d)\.(\d+)\.\d+/s;
$myarflags = 'rcD' if ($maj && $min && $maj >= 2 && $min >= 20) || $arver=~ /^BSD ar /;
}
@EUMM_INC_LIB = (
INC => '-DLTM_DESC -Isrc/ltc/headers -Isrc/ltm',
MYEXTLIB => "src/liballinone$Config{lib_ext}",
clean => { 'FILES' => join(' ', @myobjs, "src/liballinone$Config{lib_ext}") },
);
}
my %eumm_args = (
NAME => 'CryptX',
VERSION_FROM => 'lib/CryptX.pm',
AUTHOR => 'Karel Miko',
ABSTRACT => 'Crypto toolkit',
MIN_PERL_VERSION => '5.006',
LICENSE => 'perl_5',
META_MERGE => { resources => { repository => 'https://github.com/DCIT/perl-CryptX', bugtracker => 'https://github.com/DCIT/perl-CryptX/issues' } },
dist => { 'PREOP' => 'perldoc -u lib/CryptX.pm | pod2markdown > README.md' },
@EUMM_INC_LIB
);
my $eumm_ver = eval $ExtUtils::MakeMaker::VERSION;
delete $eumm_args{MIN_PERL_VERSION} if $eumm_ver < 6.48;
delete $eumm_args{META_ADD} if $eumm_ver < 6.46;
delete $eumm_args{META_MERGE} if $eumm_ver < 6.46;
delete $eumm_args{LICENSE} if $eumm_ver < 6.31;
WriteMakefile(%eumm_args);
sub MY::postamble {
return "" unless $mycflags && $myarflags;
my $extra_targets = qq{
\$(MYEXTLIB): src/Makefile
cd src && \$(MAKE) ARFLAGS="$myarflags" RANLIB="\$(RANLIB)" AR="\$(AR)" CC="\$(CC)" LIB_EXT=\$(LIB_EXT) OBJ_EXT=\$(OBJ_EXT) CFLAGS="$mycflags"
};
$extra_targets = qq{
\$(MYEXTLIB): src/Makefile
cd src && \$(MAKE) -f Makefile.nmake CFLAGS="$mycflags"
} if $^O eq 'MSWin32' && $Config{make} =~ /nmake/ && $Config{cc} =~ /cl/;
$extra_targets = qq{
\$(MYEXTLIB): src/Makefile
cd src && \$(MAKE) CC="$Config{cc}" CFLAGS="$mycflags"
} if $^O eq 'MSWin32' && $Config{cc} =~ /gcc/;
$extra_targets .= q{
versionsync:
$(NOECHO) perl _generators/version_patch.pl sync
versioninc:
$(NOECHO) perl _generators/version_patch.pl inc
versionincdev:
$(NOECHO) perl _generators/version_patch.pl incdev
versiondec:
$(NOECHO) perl _generators/version_patch.pl dec
versiondecdev:
$(NOECHO) perl _generators/version_patch.pl decdev
gencode:
$(NOECHO) perl _generators/gen.pl gencode
gentest: all
$(NOECHO) perl _generators/gen.pl gentest
openssltest: all
$(NOECHO) perl -Mblib t/openssl/dsa-test.pl
$(NOECHO) perl -Mblib t/openssl/ecc-test.pl
$(NOECHO) perl -Mblib t/openssl/rsa-test.pl
rebuild-pre:
$(RM_F) src/liballinone.a
$(TOUCH) CryptX.xs
rebuild: rebuild-pre all
};
return $extra_targets;
}

View File

@ -1,73 +0,0 @@
# NAME
CryptX - Cryptographic toolkit (self-contained, no external libraries needed)
# DESCRIPTION
Cryptography in CryptX is based on [https://github.com/libtom/libtomcrypt](https://github.com/libtom/libtomcrypt)
Available modules:
- Symmetric ciphers - see [Crypt::Cipher](https://metacpan.org/pod/Crypt::Cipher) and related modules
[Crypt::Cipher::AES](https://metacpan.org/pod/Crypt::Cipher::AES), [Crypt::Cipher::Anubis](https://metacpan.org/pod/Crypt::Cipher::Anubis), [Crypt::Cipher::Blowfish](https://metacpan.org/pod/Crypt::Cipher::Blowfish), [Crypt::Cipher::Camellia](https://metacpan.org/pod/Crypt::Cipher::Camellia), [Crypt::Cipher::CAST5](https://metacpan.org/pod/Crypt::Cipher::CAST5), [Crypt::Cipher::DES](https://metacpan.org/pod/Crypt::Cipher::DES),
[Crypt::Cipher::DES\_EDE](https://metacpan.org/pod/Crypt::Cipher::DES_EDE), [Crypt::Cipher::IDEA](https://metacpan.org/pod/Crypt::Cipher::IDEA), [Crypt::Cipher::KASUMI](https://metacpan.org/pod/Crypt::Cipher::KASUMI), [Crypt::Cipher::Khazad](https://metacpan.org/pod/Crypt::Cipher::Khazad), [Crypt::Cipher::MULTI2](https://metacpan.org/pod/Crypt::Cipher::MULTI2), [Crypt::Cipher::Noekeon](https://metacpan.org/pod/Crypt::Cipher::Noekeon),
[Crypt::Cipher::RC2](https://metacpan.org/pod/Crypt::Cipher::RC2), [Crypt::Cipher::RC5](https://metacpan.org/pod/Crypt::Cipher::RC5), [Crypt::Cipher::RC6](https://metacpan.org/pod/Crypt::Cipher::RC6), [Crypt::Cipher::SAFERP](https://metacpan.org/pod/Crypt::Cipher::SAFERP), [Crypt::Cipher::SAFER\_K128](https://metacpan.org/pod/Crypt::Cipher::SAFER_K128), [Crypt::Cipher::SAFER\_K64](https://metacpan.org/pod/Crypt::Cipher::SAFER_K64),
[Crypt::Cipher::SAFER\_SK128](https://metacpan.org/pod/Crypt::Cipher::SAFER_SK128), [Crypt::Cipher::SAFER\_SK64](https://metacpan.org/pod/Crypt::Cipher::SAFER_SK64), [Crypt::Cipher::SEED](https://metacpan.org/pod/Crypt::Cipher::SEED), [Crypt::Cipher::Serpent](https://metacpan.org/pod/Crypt::Cipher::Serpent), [Crypt::Cipher::Skipjack](https://metacpan.org/pod/Crypt::Cipher::Skipjack),
[Crypt::Cipher::Twofish](https://metacpan.org/pod/Crypt::Cipher::Twofish), [Crypt::Cipher::XTEA](https://metacpan.org/pod/Crypt::Cipher::XTEA)
- Block cipher modes
[Crypt::Mode::CBC](https://metacpan.org/pod/Crypt::Mode::CBC), [Crypt::Mode::CFB](https://metacpan.org/pod/Crypt::Mode::CFB), [Crypt::Mode::CTR](https://metacpan.org/pod/Crypt::Mode::CTR), [Crypt::Mode::ECB](https://metacpan.org/pod/Crypt::Mode::ECB), [Crypt::Mode::OFB](https://metacpan.org/pod/Crypt::Mode::OFB)
- Stream ciphers
[Crypt::Stream::RC4](https://metacpan.org/pod/Crypt::Stream::RC4), [Crypt::Stream::ChaCha](https://metacpan.org/pod/Crypt::Stream::ChaCha), [Crypt::Stream::Salsa20](https://metacpan.org/pod/Crypt::Stream::Salsa20), [Crypt::Stream::Sober128](https://metacpan.org/pod/Crypt::Stream::Sober128),
[Crypt::Stream::Sosemanuk](https://metacpan.org/pod/Crypt::Stream::Sosemanuk), [Crypt::Stream::Rabbit](https://metacpan.org/pod/Crypt::Stream::Rabbit)
- Authenticated encryption modes
[Crypt::AuthEnc::CCM](https://metacpan.org/pod/Crypt::AuthEnc::CCM), [Crypt::AuthEnc::EAX](https://metacpan.org/pod/Crypt::AuthEnc::EAX), [Crypt::AuthEnc::GCM](https://metacpan.org/pod/Crypt::AuthEnc::GCM), [Crypt::AuthEnc::OCB](https://metacpan.org/pod/Crypt::AuthEnc::OCB), [Crypt::AuthEnc::ChaCha20Poly1305](https://metacpan.org/pod/Crypt::AuthEnc::ChaCha20Poly1305)
- Hash Functions - see [Crypt::Digest](https://metacpan.org/pod/Crypt::Digest) and related modules
[Crypt::Digest::BLAKE2b\_160](https://metacpan.org/pod/Crypt::Digest::BLAKE2b_160), [Crypt::Digest::BLAKE2b\_256](https://metacpan.org/pod/Crypt::Digest::BLAKE2b_256), [Crypt::Digest::BLAKE2b\_384](https://metacpan.org/pod/Crypt::Digest::BLAKE2b_384), [Crypt::Digest::BLAKE2b\_512](https://metacpan.org/pod/Crypt::Digest::BLAKE2b_512),
[Crypt::Digest::BLAKE2s\_128](https://metacpan.org/pod/Crypt::Digest::BLAKE2s_128), [Crypt::Digest::BLAKE2s\_160](https://metacpan.org/pod/Crypt::Digest::BLAKE2s_160), [Crypt::Digest::BLAKE2s\_224](https://metacpan.org/pod/Crypt::Digest::BLAKE2s_224), [Crypt::Digest::BLAKE2s\_256](https://metacpan.org/pod/Crypt::Digest::BLAKE2s_256),
[Crypt::Digest::CHAES](https://metacpan.org/pod/Crypt::Digest::CHAES), [Crypt::Digest::MD2](https://metacpan.org/pod/Crypt::Digest::MD2), [Crypt::Digest::MD4](https://metacpan.org/pod/Crypt::Digest::MD4), [Crypt::Digest::MD5](https://metacpan.org/pod/Crypt::Digest::MD5), [Crypt::Digest::RIPEMD128](https://metacpan.org/pod/Crypt::Digest::RIPEMD128), [Crypt::Digest::RIPEMD160](https://metacpan.org/pod/Crypt::Digest::RIPEMD160),
[Crypt::Digest::RIPEMD256](https://metacpan.org/pod/Crypt::Digest::RIPEMD256), [Crypt::Digest::RIPEMD320](https://metacpan.org/pod/Crypt::Digest::RIPEMD320), [Crypt::Digest::SHA1](https://metacpan.org/pod/Crypt::Digest::SHA1), [Crypt::Digest::SHA224](https://metacpan.org/pod/Crypt::Digest::SHA224), [Crypt::Digest::SHA256](https://metacpan.org/pod/Crypt::Digest::SHA256), [Crypt::Digest::SHA384](https://metacpan.org/pod/Crypt::Digest::SHA384),
[Crypt::Digest::SHA512](https://metacpan.org/pod/Crypt::Digest::SHA512), [Crypt::Digest::SHA512\_224](https://metacpan.org/pod/Crypt::Digest::SHA512_224), [Crypt::Digest::SHA512\_256](https://metacpan.org/pod/Crypt::Digest::SHA512_256), [Crypt::Digest::Tiger192](https://metacpan.org/pod/Crypt::Digest::Tiger192), [Crypt::Digest::Whirlpool](https://metacpan.org/pod/Crypt::Digest::Whirlpool),
[Crypt::Digest::Keccak224](https://metacpan.org/pod/Crypt::Digest::Keccak224), [Crypt::Digest::Keccak256](https://metacpan.org/pod/Crypt::Digest::Keccak256), [Crypt::Digest::Keccak384](https://metacpan.org/pod/Crypt::Digest::Keccak384), [Crypt::Digest::Keccak512](https://metacpan.org/pod/Crypt::Digest::Keccak512),
[Crypt::Digest::SHA3\_224](https://metacpan.org/pod/Crypt::Digest::SHA3_224), [Crypt::Digest::SHA3\_256](https://metacpan.org/pod/Crypt::Digest::SHA3_256), [Crypt::Digest::SHA3\_384](https://metacpan.org/pod/Crypt::Digest::SHA3_384), [Crypt::Digest::SHA3\_512](https://metacpan.org/pod/Crypt::Digest::SHA3_512), [Crypt::Digest::SHAKE](https://metacpan.org/pod/Crypt::Digest::SHAKE)
- Checksums
[Crypt::Checksum::Adler32](https://metacpan.org/pod/Crypt::Checksum::Adler32), [Crypt::Checksum::CRC32](https://metacpan.org/pod/Crypt::Checksum::CRC32)
- Message Authentication Codes
[Crypt::Mac::BLAKE2b](https://metacpan.org/pod/Crypt::Mac::BLAKE2b), [Crypt::Mac::BLAKE2s](https://metacpan.org/pod/Crypt::Mac::BLAKE2s), [Crypt::Mac::F9](https://metacpan.org/pod/Crypt::Mac::F9), [Crypt::Mac::HMAC](https://metacpan.org/pod/Crypt::Mac::HMAC), [Crypt::Mac::OMAC](https://metacpan.org/pod/Crypt::Mac::OMAC),
[Crypt::Mac::Pelican](https://metacpan.org/pod/Crypt::Mac::Pelican), [Crypt::Mac::PMAC](https://metacpan.org/pod/Crypt::Mac::PMAC), [Crypt::Mac::XCBC](https://metacpan.org/pod/Crypt::Mac::XCBC), [Crypt::Mac::Poly1305](https://metacpan.org/pod/Crypt::Mac::Poly1305)
- Public key cryptography
[Crypt::PK::RSA](https://metacpan.org/pod/Crypt::PK::RSA), [Crypt::PK::DSA](https://metacpan.org/pod/Crypt::PK::DSA), [Crypt::PK::ECC](https://metacpan.org/pod/Crypt::PK::ECC), [Crypt::PK::DH](https://metacpan.org/pod/Crypt::PK::DH)
- Cryptographically secure random number generators - see [Crypt::PRNG](https://metacpan.org/pod/Crypt::PRNG) and related modules
[Crypt::PRNG::Fortuna](https://metacpan.org/pod/Crypt::PRNG::Fortuna), [Crypt::PRNG::Yarrow](https://metacpan.org/pod/Crypt::PRNG::Yarrow), [Crypt::PRNG::RC4](https://metacpan.org/pod/Crypt::PRNG::RC4), [Crypt::PRNG::Sober128](https://metacpan.org/pod/Crypt::PRNG::Sober128), [Crypt::PRNG::ChaCha20](https://metacpan.org/pod/Crypt::PRNG::ChaCha20)
- Key derivation functions - PBKDF1, PBKDF2 and HKDF
[Crypt::KeyDerivation](https://metacpan.org/pod/Crypt::KeyDerivation)
- Other handy functions related to cryptography
[Crypt::Misc](https://metacpan.org/pod/Crypt::Misc)
# LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
# COPYRIGHT
Copyright (c) 2013+ DCIT, a.s. [https://www.dcit.cz](https://www.dcit.cz) / Karel Miko

17
debian/changelog vendored
View File

@ -1,17 +0,0 @@
libcryptx-perl (0.058-1) UNRELEASED; urgency=medium
* Bump to new Version
-- Mario Fetka <mario.fetka@gmail.com> Thu, 22 Mar 2018 15:54:31 +0100
libcryptx-perl (0.048-0.1~bpo9+1) stretch-backports; urgency=medium
* Rebuild for stretch-backports.
-- Michael Prokop <mprokop@sipwise.com> Tue, 13 Jun 2017 15:33:32 +0200
libcryptx-perl (0.048-0.1) unstable; urgency=low
* Initial Release.
-- Michael Prokop <mprokop@sipwise.com> Tue, 13 Jun 2017 15:28:18 +0200

1
debian/compat vendored
View File

@ -1 +0,0 @@
9

18
debian/control vendored
View File

@ -1,18 +0,0 @@
Source: libcryptx-perl
Section: perl
Priority: optional
Maintainer: Sipwise Development Team <support@sipwise.com>
Build-Depends: debhelper,
perl
Standards-Version: 3.9.8
Homepage: https://metacpan.org/release/CryptX
Package: libcryptx-perl
Architecture: any
Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends}
Description: Crypto toolkit
Cryptography in CryptX is based on https://github.com/libtom/libtomcrypt -
being a fairly comprehensive, modular and portable cryptographic toolkit
that provides developers with a vast array of well known published block
ciphers, one-way hash functions, chaining modes, pseudo-random number
generators, public key cryptography and a plethora of other routines.

28
debian/copyright vendored
View File

@ -1,28 +0,0 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://metacpan.org/release/CryptX
Upstream-Contact: Karel Miko
Upstream-Name: CryptX
Files: *
Copyright: Karel Miko
License: Artistic or GPL-1+
Files: debian/*
Copyright: 2017, Sipwise GmbH, Austria
License: Artistic or GPL-1+
License: Artistic
This program is free software; you can redistribute it and/or modify
it under the terms of the Artistic License, which comes with Perl.
.
On Debian systems, the complete text of the Artistic License can be
found in `/usr/share/common-licenses/Artistic'.
License: GPL-1+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
.
On Debian systems, the complete text of version 1 of the GNU General
Public License can be found in `/usr/share/common-licenses/GPL-1'.

4
debian/rules vendored
View File

@ -1,4 +0,0 @@
#!/usr/bin/make -f
%:
dh $@

View File

@ -1 +0,0 @@
3.0 (quilt)

View File

@ -1,6 +0,0 @@
---
Archive: CPAN
Bug-Database: https://github.com/DCIT/perl-CryptX/issues
Contact: Karel Miko
Name: CryptX
Repository: https://github.com/DCIT/perl-CryptX

2
debian/watch vendored
View File

@ -1,2 +0,0 @@
version=3
https://metacpan.org/release/CryptX .*/CryptX-v?(\d[\d.-]*)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$

View File

@ -1,230 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::AuthEnc::CCM
PROTOTYPES: DISABLE
Crypt::AuthEnc::CCM
new(Class, char * cipher_name, SV * key, SV * nonce, SV * adata, int tag_len, int pt_len)
CODE:
{
unsigned char *k=NULL;
STRLEN k_len=0;
unsigned char *n=NULL;
STRLEN n_len=0;
unsigned char *h=NULL;
STRLEN h_len=0;
int rv, id;
if (tag_len < 1 || tag_len > MAXBLOCKSIZE) croak("FATAL: invalid tag_len %d", tag_len);
if (pt_len < 0) croak("FATAL: invalid pt_len");
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
n = (unsigned char *) SvPVbyte(nonce, n_len);
if (!SvPOK(adata)) croak("FATAL: adata must be string/buffer scalar");
h = (unsigned char *) SvPVbyte(adata, h_len);
id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
Newz(0, RETVAL, 1, ccm_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = ccm_init(RETVAL, id, k, (int)k_len, (int)pt_len, (int)tag_len, (int)h_len); /* XXX-TODO why int? */
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: ccm_init failed: %s", error_to_string(rv));
}
rv = ccm_add_nonce(RETVAL, n, (unsigned long)n_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: ccm_add_nonce failed: %s", error_to_string(rv));
}
rv = ccm_add_aad(RETVAL, h, (unsigned long)h_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: ccm_add_aad failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::AuthEnc::CCM self)
CODE:
Safefree(self);
Crypt::AuthEnc::CCM
clone(Crypt::AuthEnc::CCM self)
CODE:
Newz(0, RETVAL, 1, ccm_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, ccm_state);
OUTPUT:
RETVAL
SV *
encrypt_add(Crypt::AuthEnc::CCM self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = ccm_process(self, in_data, (unsigned long)in_data_len, out_data, CCM_ENCRYPT);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ccm_process failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
decrypt_add(Crypt::AuthEnc::CCM self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = ccm_process(self, out_data, (unsigned long)in_data_len, in_data, CCM_DECRYPT);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ccm_process failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
void
encrypt_done(Crypt::AuthEnc::CCM self)
PPCODE:
{
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = MAXBLOCKSIZE;
rv = ccm_done(self, tag, &tag_len);
if (rv != CRYPT_OK) croak("FATAL: ccm_done failed: %s", error_to_string(rv));
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
void
decrypt_done(Crypt::AuthEnc::CCM self, ...)
PPCODE:
{
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = MAXBLOCKSIZE;
STRLEN expected_tag_len;
unsigned char *expected_tag;
rv = ccm_done(self, tag, &tag_len);
if (rv != CRYPT_OK) croak("FATAL: ccm_done failed: %s", error_to_string(rv));
if (items == 1) {
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
else {
if (!SvPOK(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar");
expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len);
if (expected_tag_len!=tag_len) {
XPUSHs(sv_2mortal(newSViv(0))); /* false */
}
else if (memNE(expected_tag, tag, tag_len)) {
XPUSHs(sv_2mortal(newSViv(0))); /* false */
}
else {
XPUSHs(sv_2mortal(newSViv(1))); /* true */
}
}
}
void
ccm_encrypt_authenticate(char *cipher_name, SV *key, SV *nonce, SV *header, unsigned long tag_len, SV *plaintext)
PPCODE:
{
STRLEN k_len = 0, n_len = 0, h_len = 0, pt_len = 0;
unsigned char *k = NULL, *n = NULL, *h = NULL, *pt = NULL;
int rv, id;
unsigned char tag[MAXBLOCKSIZE];
SV *output;
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len);
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvPOK(plaintext)) pt = (unsigned char *) SvPVbyte(plaintext, pt_len);
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len);
id = _find_cipher(cipher_name);
if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
output = NEWSV(0, pt_len > 0 ? pt_len : 1); /* avoid zero! */
SvPOK_only(output);
SvCUR_set(output, pt_len);
if(tag_len < 4 || tag_len > 16) tag_len = 16;
rv = ccm_memory(id, k, (unsigned long)k_len, NULL, n, (unsigned long)n_len, h, (unsigned long)h_len,
pt, (unsigned long)pt_len, (unsigned char *)SvPVX(output), tag, &tag_len, CCM_ENCRYPT);
if (rv != CRYPT_OK) {
SvREFCNT_dec(output);
croak("FATAL: ccm_memory failed: %s", error_to_string(rv));
}
XPUSHs(sv_2mortal(output));
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
void
ccm_decrypt_verify(char *cipher_name, SV *key, SV *nonce, SV *header, SV *ciphertext, SV *tagsv)
PPCODE:
{
STRLEN k_len = 0, n_len = 0, h_len = 0, ct_len = 0, t_len = 0;
unsigned char *k = NULL, *n = NULL, *h = NULL, *ct = NULL, *t = NULL;
int rv, id;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len;
SV *output;
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len);
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvPOK(ciphertext)) ct = (unsigned char *) SvPVbyte(ciphertext, ct_len);
if (SvPOK(tagsv)) t = (unsigned char *) SvPVbyte(tagsv, t_len);
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len);
id = _find_cipher(cipher_name);
if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
output = NEWSV(0, ct_len > 0 ? ct_len : 1); /* avoid zero! */
SvPOK_only(output);
SvCUR_set(output, ct_len);
tag_len = (unsigned long)t_len;
Copy(t, tag, t_len, unsigned char);
rv = ccm_memory(id, k, (unsigned long)k_len, NULL, n, (unsigned long)n_len, h, (unsigned long)h_len,
(unsigned char *)SvPVX(output), (unsigned long)ct_len, ct, tag, &tag_len, CCM_DECRYPT);
if (rv != CRYPT_OK) {
SvREFCNT_dec(output);
XPUSHs(sv_2mortal(newSVpvn(NULL,0))); /* undef */
}
else {
XPUSHs(sv_2mortal(output));
}
}

View File

@ -1,261 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::AuthEnc::ChaCha20Poly1305
PROTOTYPES: DISABLE
Crypt::AuthEnc::ChaCha20Poly1305
new(Class, SV * key, SV * nonce = NULL)
CODE:
{
int rv;
STRLEN iv_len=0, k_len=0;
unsigned char *iv=NULL, *k=NULL;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
if (nonce) {
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
iv = (unsigned char *) SvPVbyte(nonce, iv_len);
}
Newz(0, RETVAL, 1, chacha20poly1305_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = chacha20poly1305_init(RETVAL, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: chacha20poly1305_init failed: %s", error_to_string(rv));
}
if (iv && iv_len > 0) {
rv = chacha20poly1305_setiv(RETVAL, iv, (unsigned long)iv_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: chacha20poly1305_setiv failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::AuthEnc::ChaCha20Poly1305 self)
CODE:
Safefree(self);
Crypt::AuthEnc::ChaCha20Poly1305
clone(Crypt::AuthEnc::ChaCha20Poly1305 self)
CODE:
Newz(0, RETVAL, 1, chacha20poly1305_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, chacha20poly1305_state);
OUTPUT:
RETVAL
void
set_iv(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * nonce)
PPCODE:
{
int rv;
STRLEN iv_len=0;
unsigned char *iv=NULL;
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
iv = (unsigned char *) SvPVbyte(nonce, iv_len);
rv = chacha20poly1305_setiv(self, iv, (unsigned long)iv_len);
if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_setiv failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */;
}
void
set_iv_rfc7905(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * nonce, UV seqnum)
PPCODE:
{
int rv;
STRLEN iv_len=0;
unsigned char *iv=NULL;
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
iv = (unsigned char *) SvPVbyte(nonce, iv_len);
rv = chacha20poly1305_setiv_rfc7905(self, iv, (unsigned long)iv_len, (ulong64)seqnum);
if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_setiv_rfc7905 failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
adata_add(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * data)
PPCODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
rv = chacha20poly1305_add_aad(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_add_aad failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
SV *
decrypt_add(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = chacha20poly1305_decrypt(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: chacha20poly1305_decrypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
encrypt_add(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = chacha20poly1305_encrypt(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: chacha20poly1305_encrypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
void
encrypt_done(Crypt::AuthEnc::ChaCha20Poly1305 self)
PPCODE:
{
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
rv = chacha20poly1305_done(self, tag, &tag_len);
if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_done failed: %s", error_to_string(rv));
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
void
decrypt_done(Crypt::AuthEnc::ChaCha20Poly1305 self, ...)
PPCODE:
{
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
STRLEN expected_tag_len;
unsigned char *expected_tag;
rv = chacha20poly1305_done(self, tag, &tag_len);
if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_done failed: %s", error_to_string(rv));
if (items == 1) {
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
else {
if (!SvPOK(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar");
expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len);
if (expected_tag_len!=tag_len) {
XPUSHs(sv_2mortal(newSViv(0))); /* false */
}
else if (memNE(expected_tag, tag, tag_len)) {
XPUSHs(sv_2mortal(newSViv(0))); /* false */
}
else {
XPUSHs(sv_2mortal(newSViv(1))); /* true */
}
}
}
void
chacha20poly1305_encrypt_authenticate(SV *key, SV *nonce, SV *header, SV *plaintext)
PPCODE:
{
STRLEN k_len = 0, n_len = 0, h_len = 0, pt_len = 0;
unsigned char *k = NULL, *n = NULL, *h = NULL, *pt = NULL;
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
SV *output;
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len);
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvPOK(plaintext)) pt = (unsigned char *) SvPVbyte(plaintext, pt_len);
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len);
output = NEWSV(0, pt_len > 0 ? pt_len : 1); /* avoid zero! */
SvPOK_only(output);
SvCUR_set(output, pt_len);
rv = chacha20poly1305_memory(k, (unsigned long)k_len, n, (unsigned long)n_len, h, (unsigned long)h_len,
pt, (unsigned long)pt_len, (unsigned char *)SvPVX(output), tag, &tag_len,
CHACHA20POLY1305_ENCRYPT);
if (rv != CRYPT_OK) {
SvREFCNT_dec(output);
croak("FATAL: ccm_memory failed: %s", error_to_string(rv));
}
XPUSHs(sv_2mortal(output));
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
void
chacha20poly1305_decrypt_verify(SV *key, SV *nonce, SV *header, SV *ciphertext, SV *tagsv)
PPCODE:
{
STRLEN k_len = 0, n_len = 0, h_len = 0, ct_len = 0, t_len = 0;
unsigned char *k = NULL, *n = NULL, *h = NULL, *ct = NULL, *t = NULL;
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len;
SV *output;
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len);
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvPOK(ciphertext)) ct = (unsigned char *) SvPVbyte(ciphertext, ct_len);
if (SvPOK(tagsv)) t = (unsigned char *) SvPVbyte(tagsv, t_len);
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len);
output = NEWSV(0, ct_len > 0 ? ct_len : 1); /* avoid zero! */
SvPOK_only(output);
SvCUR_set(output, ct_len);
tag_len = (unsigned long)t_len;
Copy(t, tag, t_len, unsigned char);
rv = chacha20poly1305_memory(k, (unsigned long)k_len, n, (unsigned long)n_len, h, (unsigned long)h_len,
ct, (unsigned long)ct_len, (unsigned char *)SvPVX(output), tag, &tag_len,
CHACHA20POLY1305_DECRYPT);
if (rv != CRYPT_OK) {
SvREFCNT_dec(output);
XPUSHs(sv_2mortal(newSVpvn(NULL,0))); /* undef */
}
else {
XPUSHs(sv_2mortal(output));
}
}

View File

@ -1,234 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::AuthEnc::EAX
PROTOTYPES: DISABLE
Crypt::AuthEnc::EAX
new(Class, char * cipher_name, SV * key, SV * nonce, SV * adata=&PL_sv_undef)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
unsigned char *n=NULL;
STRLEN n_len=0;
unsigned char *h=NULL;
STRLEN h_len=0;
int rv, id;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvOK(adata)) { /* adata is optional param */
if (!SvPOK(adata)) croak("FATAL: adata must be string/buffer scalar");
h = (unsigned char *) SvPVbyte(adata, h_len);
}
id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
Newz(0, RETVAL, 1, eax_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = eax_init(RETVAL, id, k, (unsigned long)k_len, n, (unsigned long)n_len, h, (unsigned long)h_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: eax setup failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::AuthEnc::EAX self)
CODE:
Safefree(self);
Crypt::AuthEnc::EAX
clone(Crypt::AuthEnc::EAX self)
CODE:
Newz(0, RETVAL, 1, eax_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, eax_state);
OUTPUT:
RETVAL
SV *
encrypt_add(Crypt::AuthEnc::EAX self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = eax_encrypt(self, in_data, out_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: eax_encrypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
decrypt_add(Crypt::AuthEnc::EAX self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = eax_decrypt(self, in_data, out_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: eax_decrypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
void
encrypt_done(Crypt::AuthEnc::EAX self)
PPCODE:
{
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
rv = eax_done(self, tag, &tag_len);
if (rv != CRYPT_OK) croak("FATAL: eax_done failed: %s", error_to_string(rv));
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
void
decrypt_done(Crypt::AuthEnc::EAX self, ...)
PPCODE:
{
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
STRLEN expected_tag_len;
unsigned char *expected_tag;
rv = eax_done(self, tag, &tag_len);
if (rv != CRYPT_OK) croak("FATAL: eax_done failed: %s", error_to_string(rv));
if (items == 1) {
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
else {
if (!SvPOK(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar");
expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len);
if (expected_tag_len!=tag_len) {
XPUSHs(sv_2mortal(newSViv(0))); /* false */
}
else if (memNE(expected_tag, tag, tag_len)) {
XPUSHs(sv_2mortal(newSViv(0))); /* false */
}
else {
XPUSHs(sv_2mortal(newSViv(1))); /* true */
}
}
}
void
adata_add(Crypt::AuthEnc::EAX self, SV * adata)
PPCODE:
{
STRLEN h_len;
int rv;
unsigned char *h;
h = (unsigned char *)SvPVbyte(adata, h_len);
rv = eax_addheader(self, h, (unsigned long)h_len);
if (rv != CRYPT_OK) croak("FATAL: eax_addheader failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
eax_encrypt_authenticate(char *cipher_name, SV *key, SV *nonce, SV *header, SV *plaintext)
PPCODE:
{
STRLEN k_len = 0, n_len = 0, h_len = 0, pt_len = 0;
unsigned char *k = NULL, *n = NULL, *h = NULL, *pt = NULL;
int rv, id;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
SV *output;
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len);
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvPOK(plaintext)) pt = (unsigned char *) SvPVbyte(plaintext, pt_len);
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len);
id = _find_cipher(cipher_name);
if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
output = NEWSV(0, pt_len > 0 ? pt_len : 1); /* avoid zero! */
SvPOK_only(output);
SvCUR_set(output, pt_len);
rv = eax_encrypt_authenticate_memory(id, k, (unsigned long)k_len, n, (unsigned long)n_len,
h, (unsigned long)h_len, pt, (unsigned long)pt_len,
(unsigned char *)SvPVX(output), tag, &tag_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(output);
croak("FATAL: ccm_memory failed: %s", error_to_string(rv));
}
XPUSHs(sv_2mortal(output));
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
void
eax_decrypt_verify(char *cipher_name, SV *key, SV *nonce, SV *header, SV *ciphertext, SV *tagsv)
PPCODE:
{
STRLEN k_len = 0, n_len = 0, h_len = 0, ct_len = 0, t_len = 0;
unsigned char *k = NULL, *n = NULL, *h = NULL, *ct = NULL, *t = NULL;
int rv, id, stat = 0;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len;
SV *output;
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len);
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvPOK(ciphertext)) ct = (unsigned char *) SvPVbyte(ciphertext, ct_len);
if (SvPOK(tagsv)) t = (unsigned char *) SvPVbyte(tagsv, t_len);
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len);
id = _find_cipher(cipher_name);
if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
output = NEWSV(0, ct_len > 0 ? ct_len : 1); /* avoid zero! */
SvPOK_only(output);
SvCUR_set(output, ct_len);
tag_len = (unsigned long)t_len;
Copy(t, tag, t_len, unsigned char);
rv = eax_decrypt_verify_memory(id, k, (unsigned long)k_len, n, (unsigned long)n_len, h, (unsigned long)h_len,
ct, (unsigned long)ct_len, (unsigned char *)SvPVX(output), tag, tag_len, &stat);
if (rv != CRYPT_OK || stat != 1) {
SvREFCNT_dec(output);
XPUSHs(sv_2mortal(newSVpvn(NULL,0))); /* undef */
}
else {
XPUSHs(sv_2mortal(output));
}
}

View File

@ -1,262 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::AuthEnc::GCM
PROTOTYPES: DISABLE
Crypt::AuthEnc::GCM
new(Class, char * cipher_name, SV * key, SV * nonce = NULL)
CODE:
{
STRLEN k_len = 0, iv_len = 0;
unsigned char *k = NULL, *iv = NULL;
int id, rv;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
if (nonce) {
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
iv = (unsigned char *)SvPVbyte(nonce, iv_len);
}
id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
Newz(0, RETVAL, 1, gcm_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = gcm_init(RETVAL, id, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: gcm_init failed: %s", error_to_string(rv));
}
if (iv && iv_len > 0) {
rv = gcm_add_iv(RETVAL, iv, (unsigned long)iv_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: gcm_add_iv failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::AuthEnc::GCM self)
CODE:
Safefree(self);
Crypt::AuthEnc::GCM
clone(Crypt::AuthEnc::GCM self)
CODE:
Newz(0, RETVAL, 1, gcm_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, gcm_state);
OUTPUT:
RETVAL
void
reset(Crypt::AuthEnc::GCM self)
PPCODE:
{
int rv;
rv = gcm_reset(self);
if (rv != CRYPT_OK) croak("FATAL: gcm_reset failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
SV *
encrypt_add(Crypt::AuthEnc::GCM self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else
{
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = gcm_process(self, in_data, (unsigned long)in_data_len, out_data, GCM_ENCRYPT);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: encrypt_add/gcm_process failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
void
iv_add(Crypt::AuthEnc::GCM self, SV * data)
PPCODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
rv = gcm_add_iv(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: gcm_add_iv failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
adata_add(Crypt::AuthEnc::GCM self, SV * data)
PPCODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
rv = gcm_add_aad(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: gcm_add_aad failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
SV *
decrypt_add(Crypt::AuthEnc::GCM self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = gcm_process(self, out_data, (unsigned long)in_data_len, in_data, GCM_DECRYPT);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: encrypt_add/gcm_process failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
void
encrypt_done(Crypt::AuthEnc::GCM self)
PPCODE:
{
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
rv = gcm_done(self, tag, &tag_len);
if (rv != CRYPT_OK) croak("FATAL: gcm_done failed: %s", error_to_string(rv));
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
void
decrypt_done(Crypt::AuthEnc::GCM self, ...)
PPCODE:
{
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
STRLEN expected_tag_len;
unsigned char *expected_tag;
rv = gcm_done(self, tag, &tag_len);
if (rv != CRYPT_OK) croak("FATAL: gcm_done failed: %s", error_to_string(rv));
if (items == 1) {
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
else {
if (!SvPOK(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar");
expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len);
if (expected_tag_len!=tag_len) {
XPUSHs(sv_2mortal(newSViv(0))); /* false */
}
else if (memNE(expected_tag, tag, tag_len)) {
XPUSHs(sv_2mortal(newSViv(0))); /* false */
}
else {
XPUSHs(sv_2mortal(newSViv(1))); /* true */
}
}
}
void
gcm_encrypt_authenticate(char *cipher_name, SV *key, SV *nonce, SV *header = NULL, SV *plaintext)
PPCODE:
{
STRLEN k_len = 0, n_len = 0, h_len = 0, pt_len = 0;
unsigned char *k = NULL, *n = NULL, *h = NULL, *pt = NULL;
int rv, id;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
SV *output;
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len);
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvPOK(plaintext)) pt = (unsigned char *) SvPVbyte(plaintext, pt_len);
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len);
id = _find_cipher(cipher_name);
if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
output = NEWSV(0, pt_len > 0 ? pt_len : 1); /* avoid zero! */
SvPOK_only(output);
SvCUR_set(output, pt_len);
rv = gcm_memory(id, k, (unsigned long)k_len, n, (unsigned long)n_len, h, (unsigned long)h_len,
pt, (unsigned long)pt_len, (unsigned char *)SvPVX(output), tag, &tag_len, GCM_ENCRYPT);
if (rv != CRYPT_OK) {
SvREFCNT_dec(output);
croak("FATAL: ccm_memory failed: %s", error_to_string(rv));
}
XPUSHs(sv_2mortal(output));
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
void
gcm_decrypt_verify(char *cipher_name, SV *key, SV *nonce, SV *header, SV *ciphertext, SV *tagsv)
PPCODE:
{
STRLEN k_len = 0, n_len = 0, h_len = 0, ct_len = 0, t_len = 0;
unsigned char *k = NULL, *n = NULL, *h = NULL, *ct = NULL, *t = NULL;
int rv, id;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len;
SV *output;
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len);
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvPOK(ciphertext)) ct = (unsigned char *) SvPVbyte(ciphertext, ct_len);
if (SvPOK(tagsv)) t = (unsigned char *) SvPVbyte(tagsv, t_len);
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len);
id = _find_cipher(cipher_name);
if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
output = NEWSV(0, ct_len > 0 ? ct_len : 1); /* avoid zero! */
SvPOK_only(output);
SvCUR_set(output, ct_len);
tag_len = (unsigned long)t_len;
Copy(t, tag, t_len, unsigned char);
rv = gcm_memory(id, k, (unsigned long)k_len, n, (unsigned long)n_len, h, (unsigned long)h_len,
(unsigned char *)SvPVX(output), (unsigned long)ct_len, ct, tag, &tag_len, GCM_DECRYPT);
if (rv != CRYPT_OK) {
SvREFCNT_dec(output);
XPUSHs(sv_2mortal(newSVpvn(NULL,0))); /* undef */
}
else {
XPUSHs(sv_2mortal(output));
}
}

View File

@ -1,298 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::AuthEnc::OCB
PROTOTYPES: DISABLE
Crypt::AuthEnc::OCB
new(Class, char * cipher_name, SV * key, SV * nonce, unsigned long taglen)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
unsigned char *n=NULL;
STRLEN n_len=0;
int rv, id;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
n = (unsigned char *) SvPVbyte(nonce, n_len);
id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
Newz(0, RETVAL, 1, ocb3_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = ocb3_init(RETVAL, id, k, (unsigned long)k_len, n, (unsigned long)n_len, taglen);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: ocb setup failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::AuthEnc::OCB self)
CODE:
Safefree(self);
Crypt::AuthEnc::OCB
clone(Crypt::AuthEnc::OCB self)
CODE:
Newz(0, RETVAL, 1, ocb3_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, ocb3_state);
OUTPUT:
RETVAL
void
adata_add(Crypt::AuthEnc::OCB self, SV * data)
PPCODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len>0) {
rv = ocb3_add_aad(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: ocb3_add_aad failed: %s", error_to_string(rv));
}
XPUSHs(ST(0)); /* return self */
}
SV *
encrypt_add(Crypt::AuthEnc::OCB self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
if (in_data_len % 16) {
croak ("FATAL: sizeof(data) should be multiple of 16");
}
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = ocb3_encrypt(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ocb3_encrypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
encrypt_last(Crypt::AuthEnc::OCB self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
rv = ocb3_encrypt_last(self, in_data, 0, NULL);
if (rv != CRYPT_OK) {
croak("FATAL: ocb3_encrypt_last failed: %s", error_to_string(rv));
}
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = ocb3_encrypt_last(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ocb3_encrypt_last failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
decrypt_add(Crypt::AuthEnc::OCB self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
if (in_data_len % 16) {
croak ("FATAL: sizeof(data) should be multiple of 16");
}
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = ocb3_decrypt(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ocb3_decrypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
decrypt_last(Crypt::AuthEnc::OCB self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
rv = ocb3_decrypt_last(self, in_data, 0, NULL);
if (rv != CRYPT_OK) {
croak("FATAL: ocb3_encrypt_last failed: %s", error_to_string(rv));
}
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = ocb3_decrypt_last(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ocb3_encrypt_last failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
void
encrypt_done(Crypt::AuthEnc::OCB self)
PPCODE:
{
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
rv = ocb3_done(self, tag, &tag_len);
if (rv != CRYPT_OK) croak("FATAL: ocb3_done_encrypt failed: %s", error_to_string(rv));
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
void
decrypt_done(Crypt::AuthEnc::OCB self, ...)
PPCODE:
{
int rv;
unsigned char tag[MAXBLOCKSIZE];
unsigned long tag_len = sizeof(tag);
STRLEN expected_tag_len;
unsigned char *expected_tag;
rv = ocb3_done(self, tag, &tag_len);
if (rv != CRYPT_OK) croak("FATAL: ocb3_done_decrypt failed: %s", error_to_string(rv));
if (items == 1) {
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
else {
if (!SvPOK(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar");
expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len);
if (expected_tag_len!=tag_len) {
XPUSHs(sv_2mortal(newSViv(0))); /* false */
}
else if (memNE(expected_tag, tag, tag_len)) {
XPUSHs(sv_2mortal(newSViv(0))); /* false */
}
else {
XPUSHs(sv_2mortal(newSViv(1))); /* true */
}
}
}
void
ocb_encrypt_authenticate(char *cipher_name, SV *key, SV *nonce, SV *header, unsigned long tag_len, SV *plaintext)
PPCODE:
{
STRLEN k_len = 0, n_len = 0, h_len = 0, pt_len = 0;
unsigned char *k = NULL, *n = NULL, *h = NULL, *pt = NULL;
int rv, id;
unsigned char tag[MAXBLOCKSIZE];
SV *output;
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len);
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvPOK(plaintext)) pt = (unsigned char *) SvPVbyte(plaintext, pt_len);
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len);
id = _find_cipher(cipher_name);
if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
output = NEWSV(0, pt_len > 0 ? pt_len : 1); /* avoid zero! */
SvPOK_only(output);
SvCUR_set(output, pt_len);
if(tag_len < 4 || tag_len > 16) tag_len = 16;
rv = ocb3_encrypt_authenticate_memory(id, k, (unsigned long)k_len, n, (unsigned long)n_len,
h, (unsigned long)h_len, pt, (unsigned long)pt_len,
(unsigned char *)SvPVX(output), tag, &tag_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(output);
croak("FATAL: ccm_memory failed: %s", error_to_string(rv));
}
XPUSHs(sv_2mortal(output));
XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
}
void
ocb_decrypt_verify(char *cipher_name, SV *key, SV *nonce, SV *header, SV *ciphertext, SV *tagsv)
PPCODE:
{
STRLEN k_len = 0, n_len = 0, h_len = 0, ct_len = 0, t_len = 0;
unsigned char *k = NULL, *n = NULL, *h = NULL, *ct = NULL, *t = NULL;
int rv, id, stat = 0;
SV *output;
if (SvPOK(key)) k = (unsigned char *) SvPVbyte(key, k_len);
if (SvPOK(nonce)) n = (unsigned char *) SvPVbyte(nonce, n_len);
if (SvPOK(ciphertext)) ct = (unsigned char *) SvPVbyte(ciphertext, ct_len);
if (SvPOK(tagsv)) t = (unsigned char *) SvPVbyte(tagsv, t_len);
if (SvPOK(header)) h = (unsigned char *) SvPVbyte(header, h_len);
id = _find_cipher(cipher_name);
if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
output = NEWSV(0, ct_len > 0 ? ct_len : 1); /* avoid zero! */
SvPOK_only(output);
SvCUR_set(output, ct_len);
rv = ocb3_decrypt_verify_memory(id, k, (unsigned long)k_len, n, (unsigned long)n_len,
h, (unsigned long)h_len, ct, (unsigned long)ct_len,
(unsigned char *)SvPVX(output), t, (unsigned long)t_len, &stat);
if (rv != CRYPT_OK || stat != 1) {
SvREFCNT_dec(output);
XPUSHs(sv_2mortal(newSVpvn(NULL,0))); /* undef */
}
else {
XPUSHs(sv_2mortal(output));
}
}

View File

@ -1,659 +0,0 @@
MODULE = CryptX PACKAGE = Math::BigInt::LTM
PROTOTYPES: DISABLE
##############################################################################
# _new()
Math::BigInt::LTM
_new(Class, SV *x)
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
if ((SvUOK(x) || SvIOK(x)) && (sizeof(UV) <= sizeof(unsigned long) || SvUV(x) == (unsigned long)SvUV(x))) {
mp_set_int(RETVAL, (unsigned long)SvUV(x));
}
else {
mp_read_radix(RETVAL, SvPV_nolen(x), 10);
}
OUTPUT:
RETVAL
##############################################################################
# _from_bin()
Math::BigInt::LTM
_from_bin(Class, SV *x)
PREINIT:
char *str, *start;
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
str = SvPV_nolen(x);
start = (strlen(str)>2 && str[0] == '0' && str[1] == 'b') ? str+2 : str;
mp_read_radix(RETVAL, start, 2);
OUTPUT:
RETVAL
##############################################################################
# _from_hex()
Math::BigInt::LTM
_from_hex(Class, SV *x)
PREINIT:
char *str, *start;
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
str = SvPV_nolen(x);
start = (strlen(str)>2 && str[0] == '0' && str[1] == 'x') ? str+2 : str;
mp_read_radix(RETVAL, start, 16);
OUTPUT:
RETVAL
##############################################################################
# _from_oct()
Math::BigInt::LTM
_from_oct(Class, SV *x)
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
mp_read_radix(RETVAL, SvPV_nolen(x), 8);
OUTPUT:
RETVAL
##############################################################################
# _set() - set an already existing object to the given scalar value
void
_set(Class, Math::BigInt::LTM n, SV *x)
CODE:
mp_set_int(n, (unsigned long)SvIV(x));
##############################################################################
# _zero()
Math::BigInt::LTM
_zero(Class)
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
mp_set_int(RETVAL, 0);
OUTPUT:
RETVAL
##############################################################################
# _one()
Math::BigInt::LTM
_one(Class)
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
mp_set_int(RETVAL, 1);
OUTPUT:
RETVAL
##############################################################################
# _two()
Math::BigInt::LTM
_two(Class)
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
mp_set_int(RETVAL, 2);
OUTPUT:
RETVAL
##############################################################################
# _ten()
Math::BigInt::LTM
_ten(Class)
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
mp_set_int(RETVAL, 10);
OUTPUT:
RETVAL
##############################################################################
# _1ex()
Math::BigInt::LTM
_1ex(Class, int x)
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
mp_set_int(RETVAL, 10);
mp_expt_d(RETVAL, x, RETVAL);
OUTPUT:
RETVAL
##############################################################################
# DESTROY() - free memory of a GMP number
void
DESTROY(Math::BigInt::LTM n)
PPCODE:
if (n) {
mp_clear(n);
Safefree(n);
}
##############################################################################
# _str() - return string so that atof() and atoi() can use it
SV *
_str(Class, Math::BigInt::LTM n)
PREINIT:
int len;
char *buf;
CODE:
if (mp_iszero(n) == MP_YES) {
RETVAL = newSVpv("0", 0);
}
else {
len = mp_count_bits(n) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */
Newz(0, buf, len, char);
mp_toradix_n(n, buf, 10, len);
RETVAL = newSVpv(buf, 0);
Safefree(buf);
}
OUTPUT:
RETVAL
##############################################################################
# _len() - return the length of the number in base 10 (costly)
int
_len(Class, Math::BigInt::LTM n)
PREINIT:
int len;
char *buf;
CODE:
if (mp_iszero(n) == MP_YES) {
RETVAL = 1;
}
else {
len = mp_count_bits(n) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */
Newz(0, buf, len, char);
mp_toradix_n(n, buf, 10, len);
RETVAL = (int)strlen(buf);
Safefree(buf);
}
OUTPUT:
RETVAL
##############################################################################
# _alen() - return the approx. length of the number in base 10 (fast)
# _alen() might underestimate, but never overestimate the true value
int
_alen(Class, Math::BigInt::LTM n)
PREINIT:
int bits;
CODE:
bits = mp_count_bits(n);
/* alen = round(bits * log(2) / log(10)) */
RETVAL = (bits < 5) ? 1 : (int)(bits * 0.301029995663 + 0.499999999999);
/* less accurate approximation, but without floating-point calculations
RETVAL = (bits < 5) ? 1 : bits / 4 + bits / 32 + bits / 64 + bits / 256;
RETVAL = (bits < 5) ? 1 : bits / 4;
*/
OUTPUT:
RETVAL
##############################################################################
# _zeros() - return number of trailing zeros (in decimal form)
int
_zeros(Class, Math::BigInt::LTM n)
PREINIT:
int len;
char *buf;
CODE:
if (mp_iszero(n) == MP_YES) {
RETVAL = 0; /* '0' has no trailing zeros! */
}
else {
len = mp_count_bits(n) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */
Newz(0, buf, len, char);
mp_toradix_n(n, buf, 10, len);
len = (int)strlen(buf);
RETVAL = 0;
while (len > 0) {
if (buf[len-1] != '0') break;
RETVAL++;
len--;
}
Safefree(buf);
}
OUTPUT:
RETVAL
##############################################################################
# _as_hex() - return ref to hexadecimal string (prefixed with 0x)
SV *
_as_hex(Class, Math::BigInt::LTM n)
PREINIT:
int i, len;
char *buf;
CODE:
len = mp_unsigned_bin_size(n) * 2 + 3;
RETVAL = newSV(len);
SvPOK_on(RETVAL);
buf = SvPVX(RETVAL); /* get ptr to storage */
*buf++ = '0'; *buf++ = 'x'; /* prepend '0x' */
mp_tohex(n, buf);
for (i=0; i<len && buf[i]>0; i++) buf[i] = toLOWER(buf[i]);
SvCUR_set(RETVAL, strlen(buf)+2); /* set real length */
OUTPUT:
RETVAL
##############################################################################
# _as_bin() - return ref to binary string (prefixed with 0b)
SV *
_as_bin(Class, Math::BigInt::LTM n)
PREINIT:
int len;
char *buf;
CODE:
len = mp_unsigned_bin_size(n) * 8 + 3;
RETVAL = newSV(len);
SvPOK_on(RETVAL);
buf = SvPVX(RETVAL); /* get ptr to storage */
*buf++ = '0'; *buf++ = 'b'; /* prepend '0b' */
mp_tobinary(n, buf);
SvCUR_set(RETVAL, strlen(buf)+2); /* set real length */
OUTPUT:
RETVAL
##############################################################################
# _as_oct() - return ref to octal string (prefixed with 0)
SV *
_as_oct(Class, Math::BigInt::LTM n)
PREINIT:
int len;
char *buf;
CODE:
len = mp_unsigned_bin_size(n) * 3 + 3;
RETVAL = newSV(len);
SvPOK_on(RETVAL);
buf = SvPVX(RETVAL);
*buf++ = '0'; /* prepend '0' */
mp_tooctal(n, buf);
SvCUR_set(RETVAL, strlen(buf)+1); /* set real length */
OUTPUT:
RETVAL
##############################################################################
# _modpow() - ($n ** $exp) % $mod
Math::BigInt::LTM
_modpow(Class, Math::BigInt::LTM n, Math::BigInt::LTM exp, Math::BigInt::LTM mod)
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
if (mp_cmp_d(mod, 1) == MP_EQ) {
mp_set_int(RETVAL, 0);
}
else {
mp_exptmod(n, exp, mod, RETVAL);
}
OUTPUT:
RETVAL
##############################################################################
# _modinv() - compute the inverse of x % y
void
_modinv(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PREINIT:
int rc;
SV* s;
mp_int* RETVAL;
PPCODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
rc = mp_invmod(x, y, RETVAL);
EXTEND(SP, 2); /* we return two values */
if (rc != MP_OKAY) {
/* Inverse doesn't exist. Return both values undefined. */
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_undef);
}
else {
/* Inverse exists. When the modulus to mp_invert() is positive,
* the returned value is also positive. */
PUSHs(sv_2mortal(sv_from_mpi(RETVAL)));
s = sv_newmortal();
sv_setpvn(s, "+", 1);
PUSHs(s);
}
##############################################################################
# _add() - add $y to $x in place
void
_add(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PPCODE:
mp_add(x, y, x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _inc() - modify x inline by doing x++
void
_inc(Class, Math::BigInt::LTM x)
PPCODE:
mp_add_d(x, 1, x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _dec() - modify x inline by doing x--
void
_dec(Class, Math::BigInt::LTM x)
PPCODE:
mp_sub_d(x, 1, x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _sub() - $x - $y
# $x is always larger than $y! So overflow/underflow can not happen here.
void
_sub(Class, Math::BigInt::LTM x, Math::BigInt::LTM y, ...)
PPCODE:
if ( items == 4 && SvTRUE(ST(3)) ) {
/* y -= x */
mp_sub(x, y, y);
XPUSHs(ST(2)); /* y */
}
else {
/* x -= y */
mp_sub(x, y, x);
XPUSHs(ST(1)); /* x */
}
##############################################################################
# _rsft()
void
_rsft(Class, Math::BigInt::LTM x, Math::BigInt::LTM y, unsigned long base_int)
PREINIT:
mp_int* BASE;
PPCODE:
Newz(0, BASE, 1, mp_int);
mp_init_set_int(BASE, base_int);
mp_expt_d(BASE, mp_get_long(y), BASE);
mp_div(x, BASE, x, NULL);
mp_clear(BASE);
Safefree(BASE);
XPUSHs(ST(1)); /* x */
##############################################################################
# _lsft()
void
_lsft(Class, Math::BigInt::LTM x, Math::BigInt::LTM y, unsigned long base_int)
PREINIT:
mp_int* BASE;
PPCODE:
Newz(0, BASE, 1, mp_int);
mp_init_set_int(BASE, base_int);
mp_expt_d(BASE, mp_get_long(y), BASE);
mp_mul(x, BASE, x);
mp_clear(BASE);
Safefree(BASE);
XPUSHs(ST(1)); /* x */
##############################################################################
# _mul()
void
_mul(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PPCODE:
mp_mul(x, y, x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _div(): x /= y or (x,rem) = x / y
void
_div(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PREINIT:
mp_int * rem;
PPCODE:
if (GIMME_V == G_ARRAY) {
Newz(0, rem, 1, mp_int);
mp_init(rem);
mp_div(x, y, x, rem);
EXTEND(SP, 2);
PUSHs(ST(1)); /* x */
PUSHs(sv_2mortal(sv_from_mpi(rem)));
}
else {
mp_div(x, y, x, NULL);
XPUSHs(ST(1)); /* x */
}
##############################################################################
# _mod() - x %= y
void
_mod(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PPCODE:
mp_mod(x, y, x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _acmp() - cmp two numbers
int
_acmp(Class, Math::BigInt::LTM m, Math::BigInt::LTM n)
CODE:
RETVAL = mp_cmp(m, n);
if ( RETVAL < 0) RETVAL = -1;
if ( RETVAL > 0) RETVAL = 1;
OUTPUT:
RETVAL
##############################################################################
# _is_zero()
int
_is_zero(Class, Math::BigInt::LTM x)
CODE:
RETVAL = (mp_iszero(x) == MP_YES) ? 1 : 0;
OUTPUT:
RETVAL
##############################################################################
# _is_one()
int
_is_one(Class, Math::BigInt::LTM x)
CODE:
RETVAL = (mp_cmp_d(x, 1) == MP_EQ) ? 1 : 0;
OUTPUT:
RETVAL
##############################################################################
# _is_two()
int
_is_two(Class, Math::BigInt::LTM x)
CODE:
RETVAL = (mp_cmp_d(x, 2) == MP_EQ) ? 1 : 0;
OUTPUT:
RETVAL
##############################################################################
# _is_ten()
int
_is_ten(Class, Math::BigInt::LTM x)
CODE:
RETVAL = (mp_cmp_d(x, 10) == MP_EQ) ? 1 : 0;
OUTPUT:
RETVAL
##############################################################################
# _pow() - x **= y
void
_pow(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PPCODE:
mp_expt_d(x, mp_get_long(y), x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _gcd() - gcd(m,n)
Math::BigInt::LTM
_gcd(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
mp_gcd(x, y, RETVAL);
OUTPUT:
RETVAL
##############################################################################
# _and() - m &= n
void
_and(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PPCODE:
mp_and(x, y, x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _xor() - m =^ n
void
_xor(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PPCODE:
mp_xor(x, y, x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _or() - m =| n
void
_or(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PPCODE:
mp_or(x, y, x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _copy()
Math::BigInt::LTM
_copy(Class, Math::BigInt::LTM m)
CODE:
Newz(0, RETVAL, 1, mp_int);
mp_init(RETVAL);
mp_copy(m, RETVAL);
OUTPUT:
RETVAL
##############################################################################
# _is_odd() - test for number being odd
int
_is_odd(Class, Math::BigInt::LTM n)
CODE:
RETVAL = (mp_isodd(n) == MP_YES) ? 1 : 0;
OUTPUT:
RETVAL
##############################################################################
# _is_even() - test for number being even
int
_is_even(Class, Math::BigInt::LTM n)
CODE:
RETVAL = (mp_iseven(n) == MP_YES || mp_iszero(n) == MP_YES) ? 1 : 0;
OUTPUT:
RETVAL
##############################################################################
# _sqrt() - square root
void
_sqrt(Class, Math::BigInt::LTM x)
PPCODE:
mp_sqrt(x, x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _root() - integer roots
void
_root(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PPCODE:
mp_n_root(x, mp_get_long(y), x);
XPUSHs(ST(1)); /* x */
##############################################################################
# _lcm() - least common multiple
void
_lcm(Class, Math::BigInt::LTM x, Math::BigInt::LTM y)
PPCODE:
mp_lcm(x, y, x) ;
XPUSHs(ST(1)); /* x */
##############################################################################
# Storable hooks
void
STORABLE_thaw(blank_obj, cloning, serialized, ...)
SV *blank_obj
SV *cloning = NO_INIT
SV *serialized
PREINIT:
SV *target;
mp_int *mpi;
PPCODE:
PERL_UNUSED_VAR(cloning);
if (SvROK(blank_obj) && sv_isa(blank_obj, "Math::BigInt::LTM")) {
Newz(0, mpi, 1, mp_int);
mp_init(mpi);
mp_read_radix(mpi, SvPV_nolen(serialized), 10);
target = SvRV(blank_obj);
SvIV_set(target, PTR2IV(mpi));
SvIOK_on(target);
PUSHs(target);
XSRETURN(1);
}
else
croak("Bad object for Math::BigInt::LTM::STORABLE_thaw call");
SV *
STORABLE_freeze(self, cloning = NULL)
Math::BigInt::LTM self
SV *cloning = NO_INIT
PREINIT:
unsigned long len;
char *buf;
CODE:
PERL_UNUSED_VAR(cloning);
if (mp_iszero(self) == MP_YES) {
RETVAL = newSVpv("0", 0);
}
else {
len = mp_count_bits(self) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */
Newz(0, buf, len, char);
mp_toradix_n(self, buf, 10, len);
RETVAL = newSVpv(buf, 0);
Safefree(buf);
}
OUTPUT:
RETVAL

View File

@ -1,119 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Checksum::Adler32
PROTOTYPES: DISABLE
Crypt::Checksum::Adler32
new(Class)
CODE:
{
Newz(0, RETVAL, 1, adler32_state);
if (!RETVAL) croak("FATAL: Newz failed");
adler32_init(RETVAL); /* returns void */
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Checksum::Adler32 self)
CODE:
Safefree(self);
void
reset(Crypt::Checksum::Adler32 self)
PPCODE:
{
adler32_init(self); /* returns void */
XPUSHs(ST(0)); /* return self */
}
Crypt::Checksum::Adler32
clone(Crypt::Checksum::Adler32 self)
CODE:
Newz(0, RETVAL, 1, adler32_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, adler32_state);
OUTPUT:
RETVAL
void
add(Crypt::Checksum::Adler32 self, ...)
PPCODE:
{
STRLEN inlen;
int i;
unsigned char *in;
for(i=1; i<items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
adler32_update(self, in, (unsigned long)inlen); /* returns void */
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
digest(Crypt::Checksum::Adler32 self)
ALIAS:
hexdigest = 1
intdigest = 2
CODE:
{
int rv;
unsigned char hash[4], out[8];
unsigned long outlen = 8;
unsigned int ui32;
adler32_finish(self, hash, 4); /* returns void */
if (ix == 1) {
rv = _base16_encode(hash, 4, out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *)out, outlen);
}
else if (ix == 2) {
LOAD32H(ui32, hash);
RETVAL = newSVuv(ui32);
}
else {
RETVAL = newSVpvn((char *) hash, 4);
}
}
OUTPUT:
RETVAL
SV *
adler32_data(...)
ALIAS:
adler32_data_hex = 1
adler32_data_int = 2
CODE:
{
adler32_state st;
int rv, j;
unsigned char hash[4], out[8], *in;
unsigned long outlen = 8;
unsigned int ui32;
STRLEN inlen;
adler32_init(&st);
for(j = 0; j < items; j++) {
in = (unsigned char *)SvPVbyte(ST(j), inlen);
if (inlen > 0) {
adler32_update(&st, in, (unsigned long)inlen); /* returns void */
}
}
adler32_finish(&st, hash, 4); /* returns void */
if (ix == 1) {
rv = _base16_encode(hash, 4, out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *)out, outlen);
}
else if (ix == 2) {
LOAD32H(ui32, hash);
RETVAL = newSVuv(ui32);
}
else {
RETVAL = newSVpvn((char *) hash, 4);
}
}
OUTPUT:
RETVAL

View File

@ -1,119 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Checksum::CRC32
PROTOTYPES: DISABLE
Crypt::Checksum::CRC32
new(Class)
CODE:
{
Newz(0, RETVAL, 1, crc32_state);
if (!RETVAL) croak("FATAL: Newz failed");
crc32_init(RETVAL); /* returns void */
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Checksum::CRC32 self)
CODE:
Safefree(self);
void
reset(Crypt::Checksum::CRC32 self)
PPCODE:
{
crc32_init(self); /* returns void */
XPUSHs(ST(0)); /* return self */
}
Crypt::Checksum::CRC32
clone(Crypt::Checksum::CRC32 self)
CODE:
Newz(0, RETVAL, 1, crc32_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, crc32_state);
OUTPUT:
RETVAL
void
add(Crypt::Checksum::CRC32 self, ...)
PPCODE:
{
STRLEN inlen;
int i;
unsigned char *in;
for(i=1; i<items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
crc32_update(self, in, (unsigned long)inlen); /* returns void */
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
digest(Crypt::Checksum::CRC32 self)
ALIAS:
hexdigest = 1
intdigest = 2
CODE:
{
int rv;
unsigned char hash[4], out[8];
unsigned long outlen = 8;
unsigned int ui32;
crc32_finish(self, hash, 4); /* returns void */
if (ix == 1) {
rv = _base16_encode(hash, 4, out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *)out, outlen);
}
else if (ix == 2) {
LOAD32H(ui32, hash);
RETVAL = newSVuv(ui32);
}
else {
RETVAL = newSVpvn((char *) hash, 4);
}
}
OUTPUT:
RETVAL
SV *
crc32_data(...)
ALIAS:
crc32_data_hex = 1
crc32_data_int = 2
CODE:
{
crc32_state st;
int rv, j;
unsigned char hash[4], out[8], *in;
unsigned long outlen = 8;
unsigned int ui32;
STRLEN inlen;
crc32_init(&st);
for(j = 0; j < items; j++) {
in = (unsigned char *)SvPVbyte(ST(j), inlen);
if (inlen > 0) {
crc32_update(&st, in, (unsigned long)inlen); /* returns void */
}
}
crc32_finish(&st, hash, 4); /* returns void */
if (ix == 1) {
rv = _base16_encode(hash, 4, out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *)out, outlen);
}
else if (ix == 2) {
LOAD32H(ui32, hash);
RETVAL = newSVuv(ui32);
}
else {
RETVAL = newSVpvn((char *) hash, 4);
}
}
OUTPUT:
RETVAL

View File

@ -1,187 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Cipher
PROTOTYPES: DISABLE
Crypt::Cipher
new(char * class, ...)
CODE:
{
STRLEN key_len;
unsigned char *key_data = NULL;
SV *key;
char *cipher_name;
int rv, id, rounds = 0, idx;
/* we need to handle:
Crypt::Cipher->new('AES');
Crypt::Cipher::AES->new();
*/
idx = strcmp("Crypt::Cipher", class) == 0 ? 1 : 0;
if (idx + 1 > items) croak("FATAL: missing argument");
cipher_name = SvPVX(ST(idx));
key = ST(idx + 1);
if (idx + 3 <= items) rounds = (int)SvIV(ST(idx + 2));
if (!SvPOK (key)) croak("FATAL: key must be string scalar");
key_data = (unsigned char *)SvPVbyte(key, key_len);
id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
Newz(0, RETVAL, 1, struct cipher_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->desc = &cipher_descriptor[id];
rv = RETVAL->desc->setup(key_data, (int)key_len, rounds, &RETVAL->skey);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: cipher setup failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Cipher self)
CODE:
Safefree(self);
SV *
encrypt(Crypt::Cipher self, SV * data)
CODE:
{
int rv;
STRLEN len;
void *plaintext = SvPVbyte(data, len);
if (len == 0) {
RETVAL = newSVpvn("", 0);
}
else if (len == (STRLEN)self->desc->block_length) {
RETVAL = NEWSV(0, len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, len);
rv = self->desc->ecb_encrypt((unsigned char *)plaintext, (unsigned char *)SvPVX(RETVAL), &self->skey);
if (rv!=CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: encrypt failed: %s", error_to_string(rv));
}
}
else {
croak ("FATAL: input size not equal to blocksize (%d)", self->desc->block_length);
}
}
OUTPUT:
RETVAL
SV *
decrypt(Crypt::Cipher self, SV * data)
CODE:
{
int rv;
STRLEN len;
void *ciphertext = SvPVbyte(data, len);
if (len == 0) {
RETVAL = newSVpvn("", 0);
}
else if (len == (STRLEN)self->desc->block_length) {
RETVAL = NEWSV(0, len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, len);
rv = self->desc->ecb_decrypt((unsigned char *)ciphertext, (unsigned char *)SvPVX(RETVAL), &self->skey);
if (rv!=CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: decrypt failed: %s", error_to_string(rv));
}
}
else {
croak ("FATAL: input size not equal to blocksize (%d)", self->desc->block_length);
}
}
OUTPUT:
RETVAL
int
blocksize(SV * param, char * extra = NULL)
CODE:
{
if (sv_isobject(param) && sv_derived_from(param, "Crypt::Cipher")) {
IV tmp = SvIV((SV*)SvRV(param));
Crypt__Cipher obj = INT2PTR(Crypt__Cipher, tmp);
RETVAL = obj->desc->block_length;
}
else {
char *name = SvPOK(param) && strcmp(SvPVX(param), "Crypt::Cipher") ? SvPVX(param) : extra;
int rv, id = _find_cipher(name);
if (id == -1) croak("FATAL: find_cipher failed for '%s'", name);
rv = cipher_descriptor[id].block_length;
if (!rv) croak("FATAL: invalid block_length for '%s'", name);
RETVAL = rv;
}
}
OUTPUT:
RETVAL
int
max_keysize(SV * param, char * extra = NULL)
CODE:
{
if (sv_isobject(param) && sv_derived_from(param, "Crypt::Cipher")) {
IV tmp = SvIV((SV*)SvRV(param));
Crypt__Cipher obj = INT2PTR(Crypt__Cipher, tmp);
RETVAL = obj->desc->max_key_length;
}
else {
char *name = SvPOK(param) && strcmp(SvPVX(param), "Crypt::Cipher") ? SvPVX(param) : extra;
int rv, id = _find_cipher(name);
if (id == -1) croak("FATAL: find_cipher failed for '%s'", name);
rv = cipher_descriptor[id].max_key_length;
if (!rv) croak("FATAL: invalid max_key_length for '%s'", name);
RETVAL = rv;
}
}
OUTPUT:
RETVAL
int
min_keysize(SV * param, char * extra = NULL)
CODE:
{
if (sv_isobject(param) && sv_derived_from(param, "Crypt::Cipher")) {
IV tmp = SvIV((SV*)SvRV(param));
Crypt__Cipher obj = INT2PTR(Crypt__Cipher, tmp);
RETVAL = obj->desc->min_key_length;
}
else {
char *name = SvPOK(param) && strcmp(SvPVX(param), "Crypt::Cipher") ? SvPVX(param) : extra;
int rv, id = _find_cipher(name);
if (id == -1) croak("FATAL: find_cipher failed for '%s'", name);
rv = cipher_descriptor[id].min_key_length;
if (!rv) croak("FATAL: invalid min_key_length for '%s'", name);
RETVAL = rv;
}
}
OUTPUT:
RETVAL
int
default_rounds(SV * param, char * extra = NULL)
CODE:
{
if (sv_isobject(param) && sv_derived_from(param, "Crypt::Cipher")) {
IV tmp = SvIV((SV*)SvRV(param));
Crypt__Cipher obj = INT2PTR(Crypt__Cipher, tmp);
RETVAL = obj->desc->default_rounds;
}
else {
char *name = SvPOK(param) && strcmp(SvPVX(param), "Crypt::Cipher") ? SvPVX(param) : extra;
int rv, id = _find_cipher(name);
if (id == -1) croak("FATAL: find_cipher failed for '%s'", name);
rv = cipher_descriptor[id].default_rounds;
if (!rv) XSRETURN_UNDEF;
RETVAL = rv;
}
}
OUTPUT:
RETVAL

View File

@ -1,186 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Digest
PROTOTYPES: DISABLE
Crypt::Digest
new(char * cname, char * pname = NULL)
CODE:
{
int rv;
int id;
char *digest_name = strcmp(cname, "Crypt::Digest") == 0 ? pname : cname;
id = _find_hash(digest_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", digest_name);
Newz(0, RETVAL, 1, struct digest_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->desc = &hash_descriptor[id];
rv = RETVAL->desc->init(&RETVAL->state);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: digest setup failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Digest self)
CODE:
Safefree(self);
void
reset(Crypt::Digest self)
PPCODE:
{
int rv;
rv = self->desc->init(&self->state);
if (rv != CRYPT_OK) croak("FATAL: digest init failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
Crypt::Digest
clone(Crypt::Digest self)
CODE:
Newz(0, RETVAL, 1, struct digest_struct);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(&self->state, &RETVAL->state, 1, struct digest_struct);
OUTPUT:
RETVAL
void
add(Crypt::Digest self, ...)
PPCODE:
{
STRLEN inlen;
int rv, i;
unsigned char *in;
for(i = 1; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = self->desc->process(&self->state, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: digest process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
digest(Crypt::Digest self)
ALIAS:
hexdigest = 1
b64digest = 2
b64udigest = 3
CODE:
{
int rv;
unsigned long outlen;
unsigned char hash[MAXBLOCKSIZE];
char out[MAXBLOCKSIZE*2];
rv = self->desc->done(&self->state, hash);
if (rv != CRYPT_OK) croak("FATAL: digest done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(hash, self->desc->hashsize, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else if (ix == 2) {
rv = base64_encode(hash, self->desc->hashsize, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(hash, self->desc->hashsize, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else {
RETVAL = newSVpvn((char *) hash, self->desc->hashsize);
}
}
OUTPUT:
RETVAL
SV *
digest_data(char * digest_name, ...)
ALIAS:
digest_data_hex = 1
digest_data_b64 = 2
digest_data_b64u = 3
CODE:
{
STRLEN inlen;
int rv, id, i;
unsigned char *in, hash[MAXBLOCKSIZE];
unsigned long len = sizeof(hash), outlen;
char out[MAXBLOCKSIZE*2];
hash_state md;
id = _find_hash(digest_name);
if (id == -1) croak("FATAL: find_digest failed for '%s'", digest_name);
/* digest_data("SHA1", $data1, $data2, $data3); */
len = hash_descriptor[id].hashsize;
rv = hash_descriptor[id].init(&md);
if (rv != CRYPT_OK) croak("FATAL: digest init failed: %s", error_to_string(rv));
for (i = 1; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = hash_descriptor[id].process(&md, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: digest process failed: %s", error_to_string(rv));
}
}
rv = hash_descriptor[id].done(&md, hash);
if (rv != CRYPT_OK) croak("FATAL: digest done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(hash, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 2) {
rv = base64_encode(hash, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(hash, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else {
RETVAL = newSVpvn((char *) hash, len);
}
}
OUTPUT:
RETVAL
int
hashsize(SV * param, char * extra = NULL)
CODE:
{
if (sv_isobject(param) && sv_derived_from(param, "Crypt::Digest")) {
IV tmp = SvIV((SV*)SvRV(param));
Crypt__Digest obj = INT2PTR(Crypt__Digest, tmp);
RETVAL = obj->desc->hashsize;
}
else {
char *digest_name;
int rv, id;
digest_name = SvPOK(param) && strcmp(SvPVX(param), "Crypt::Digest") ? SvPVX(param) : extra;
id = _find_hash(digest_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", digest_name);
rv = hash_descriptor[id].hashsize;
if (!rv) croak("FATAL: invalid hashsize for '%s'", digest_name);;
RETVAL = rv;
}
}
OUTPUT:
RETVAL

View File

@ -1,89 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Digest::SHAKE
PROTOTYPES: DISABLE
Crypt::Digest::SHAKE
new(Class, int num)
CODE:
{
int rv;
Newz(0, RETVAL, 1, struct digest_shake_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->num = num;
rv = sha3_shake_init(&RETVAL->state, RETVAL->num);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: sha3_shake_init failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Digest::SHAKE self)
CODE:
Safefree(self);
void
reset(Crypt::Digest::SHAKE self)
PPCODE:
{
int rv;
rv = sha3_shake_init(&self->state, self->num);
if (rv != CRYPT_OK) croak("FATAL: sha3_shake_init failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
Crypt::Digest::SHAKE
clone(Crypt::Digest::SHAKE self)
CODE:
Newz(0, RETVAL, 1, struct digest_shake_struct);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(&self->state, &RETVAL->state, 1, struct digest_shake_struct);
OUTPUT:
RETVAL
void
add(Crypt::Digest::SHAKE self, ...)
PPCODE:
{
STRLEN inlen;
int rv, i;
unsigned char *in;
for(i=1; i<items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen>0) {
rv = sha3_shake_process(&self->state, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: sha3_shake_process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
done(Crypt::Digest::SHAKE self, STRLEN out_len)
CODE:
{
int rv;
unsigned char *out_data;
if (out_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, out_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = sha3_shake_done(&self->state, out_data, (unsigned long)out_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: sha3_shake_done failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL

View File

@ -1,174 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::KeyDerivation
PROTOTYPES: DISABLE
SV *
pbkdf1(SV * password, SV * salt, int iteration_count = 5000, const char * hash_name = "SHA256", unsigned long output_len = 32)
CODE:
{
int rv, id;
unsigned char *output;
unsigned char *password_ptr=NULL;
STRLEN password_len=0;
unsigned char *salt_ptr=NULL;
STRLEN salt_len=0;
if (output_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
password_ptr = (unsigned char *)SvPVbyte(password, password_len);
salt_ptr = (unsigned char *)SvPVbyte(salt, salt_len);
if (salt_len < 8) croak("FATAL: salt_len has to be 8");
RETVAL = NEWSV(0, output_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, output_len);
output = (unsigned char *)SvPVX(RETVAL);
rv = pkcs_5_alg1(password_ptr, (unsigned long)password_len, salt_ptr, iteration_count, id, output, &output_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: pkcs_5_alg1 process failed: %s", error_to_string(rv));
}
SvCUR_set(RETVAL, output_len);
}
}
OUTPUT:
RETVAL
SV *
pbkdf2(SV * password, SV * salt, int iteration_count = 5000, const char * hash_name = "SHA256", unsigned long output_len = 32)
CODE:
{
int rv, id;
unsigned char *output;
unsigned char *password_ptr=NULL;
STRLEN password_len=0;
unsigned char *salt_ptr=NULL;
STRLEN salt_len=0;
if (output_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
password_ptr = (unsigned char *)SvPVbyte(password, password_len);
salt_ptr = (unsigned char *)SvPVbyte(salt, salt_len);
RETVAL = NEWSV(0, output_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, output_len);
output = (unsigned char *)SvPVX(RETVAL);
rv = pkcs_5_alg2(password_ptr, (unsigned long)password_len, salt_ptr, (unsigned long)salt_len, iteration_count, id, output, &output_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: pkcs_5_alg2 process failed: %s", error_to_string(rv));
}
SvCUR_set(RETVAL, output_len);
}
}
OUTPUT:
RETVAL
SV *
hkdf_extract(SV * in, SV * salt = &PL_sv_undef, const char * hash_name = "SHA256")
CODE:
{
int rv, id;
unsigned char output[MAXBLOCKSIZE];
unsigned long output_len;
unsigned char *in_ptr = NULL, *salt_ptr = NULL;
STRLEN in_len = 0, salt_len = 0;
id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
if (SvPOK(in)) in_ptr = (unsigned char *)SvPVbyte(in, in_len);
if (SvPOK(salt)) salt_ptr = (unsigned char *)SvPVbyte(salt, salt_len);
output_len = sizeof(output);
rv = hkdf_extract(id, salt_ptr, (unsigned long)salt_len, in_ptr, (unsigned long)in_len, output, &output_len);
if (rv != CRYPT_OK) croak("FATAL: hkdf_extract process failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *)output, output_len);
}
OUTPUT:
RETVAL
SV *
hkdf_expand(SV * in, const char * hash_name = "SHA256", unsigned long output_len = 32, SV * info = &PL_sv_undef)
CODE:
{
int rv, id;
unsigned char *output;
unsigned char *in_ptr = NULL, *info_ptr = NULL;
STRLEN in_len = 0, info_len = 0;
if (output_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
if (SvPOK(in)) in_ptr = (unsigned char *)SvPVbyte(in, in_len);
if (SvPOK(info)) info_ptr = (unsigned char *)SvPVbyte(info, info_len);
RETVAL = NEWSV(0, output_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, output_len);
output = (unsigned char *)SvPVX(RETVAL);
rv = hkdf_expand(id, info_ptr, (unsigned long)info_len, in_ptr, (unsigned long)in_len, output, output_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: hkdf_expand process failed: %s", error_to_string(rv));
}
SvCUR_set(RETVAL, output_len);
}
}
OUTPUT:
RETVAL
SV *
hkdf(SV * in, SV * salt, const char * hash_name = "SHA256", unsigned long output_len = 32, SV * info = &PL_sv_undef)
CODE:
{
int rv, id;
unsigned char *output;
unsigned char *in_ptr = NULL, *info_ptr = NULL, *salt_ptr = NULL;
STRLEN in_len = 0, info_len = 0, salt_len = 0;
if (output_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
if (SvPOK(in)) in_ptr = (unsigned char *)SvPVbyte(in, in_len);
if (SvPOK(info)) info_ptr = (unsigned char *)SvPVbyte(info, info_len);
if (SvPOK(salt)) salt_ptr = (unsigned char *)SvPVbyte(salt, salt_len);
RETVAL = NEWSV(0, output_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, output_len);
output = (unsigned char *)SvPVX(RETVAL);
rv = hkdf(id, salt_ptr, (unsigned long)salt_len, info_ptr, (unsigned long)info_len, in_ptr, (unsigned long)in_len, output, output_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: hkdf_expand process failed: %s", error_to_string(rv));
}
SvCUR_set(RETVAL, output_len);
}
}
OUTPUT:
RETVAL

View File

@ -1,152 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mac::BLAKE2b
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mac::BLAKE2b
new(Class, unsigned long size, SV * key)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
int rv;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, blake2bmac_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = blake2bmac_init(RETVAL, size, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: blake2b_init failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mac::BLAKE2b self)
CODE:
Safefree(self);
Crypt::Mac::BLAKE2b
clone(Crypt::Mac::BLAKE2b self)
CODE:
Newz(0, RETVAL, 1, blake2bmac_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, blake2bmac_state);
OUTPUT:
RETVAL
void
add(Crypt::Mac::BLAKE2b self, ...)
PPCODE:
{
int rv, i;
STRLEN in_data_len;
unsigned char *in_data;
for(i = 1; i < items; i++) {
in_data = (unsigned char *)SvPVbyte(ST(i), in_data_len);
if (in_data_len > 0) {
rv = blake2bmac_process(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: blake2b_process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
mac(Crypt::Mac::BLAKE2b self)
ALIAS:
hexmac = 1
b64mac = 2
b64umac = 3
CODE:
{
unsigned char mac[MAXBLOCKSIZE];
unsigned long maclen, outlen;
int rv;
char out[MAXBLOCKSIZE*2];
maclen = sizeof(mac);
rv = blake2bmac_done(self, mac, &maclen);
if (rv != CRYPT_OK) croak("FATAL: blake2bmac_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 2) {
rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 1) {
rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else {
RETVAL = newSVpvn((char * )mac, maclen);
}
}
OUTPUT:
RETVAL
SV *
blake2b(unsigned long size, SV * key, ...)
ALIAS:
blake2b_hex = 1
blake2b_b64 = 2
blake2b_b64u = 3
CODE:
{
STRLEN inlen, klen;
unsigned char *in;
unsigned char *k = (unsigned char *)SvPVbyte(key, klen);
int rv, i;
unsigned char mac[MAXBLOCKSIZE];
unsigned long len = sizeof(mac), outlen;
char out[MAXBLOCKSIZE*2];
blake2bmac_state st;
if (size < len) len = size;
rv = blake2bmac_init(&st, len, k, (unsigned long)klen);
if (rv != CRYPT_OK) croak("FATAL: blake2bmac_init failed: %s", error_to_string(rv));
for (i = 2; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = blake2bmac_process(&st, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: blake2bmac_process failed: %s", error_to_string(rv));
}
}
rv = blake2bmac_done(&st, mac, &len);
if (rv != CRYPT_OK) croak("FATAL: blake2bmac_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 2) {
rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else {
RETVAL = newSVpvn((char *) mac, len);
}
}
OUTPUT:
RETVAL

View File

@ -1,152 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mac::BLAKE2s
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mac::BLAKE2s
new(Class, unsigned long size, SV * key)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
int rv;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, blake2smac_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = blake2smac_init(RETVAL, size, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: blake2s_init failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mac::BLAKE2s self)
CODE:
Safefree(self);
Crypt::Mac::BLAKE2s
clone(Crypt::Mac::BLAKE2s self)
CODE:
Newz(0, RETVAL, 1, blake2smac_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, blake2smac_state);
OUTPUT:
RETVAL
void
add(Crypt::Mac::BLAKE2s self, ...)
PPCODE:
{
int rv, i;
STRLEN in_data_len;
unsigned char *in_data;
for(i = 1; i < items; i++) {
in_data = (unsigned char *)SvPVbyte(ST(i), in_data_len);
if (in_data_len > 0) {
rv = blake2smac_process(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: blake2s_process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
mac(Crypt::Mac::BLAKE2s self)
ALIAS:
hexmac = 1
b64mac = 2
b64umac = 3
CODE:
{
unsigned char mac[MAXBLOCKSIZE];
unsigned long maclen, outlen;
int rv;
char out[MAXBLOCKSIZE*2];
maclen = sizeof(mac);
rv = blake2smac_done(self, mac, &maclen);
if (rv != CRYPT_OK) croak("FATAL: blake2smac_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 2) {
rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 1) {
rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else {
RETVAL = newSVpvn((char * )mac, maclen);
}
}
OUTPUT:
RETVAL
SV *
blake2s(unsigned long size, SV * key, ...)
ALIAS:
blake2s_hex = 1
blake2s_b64 = 2
blake2s_b64u = 3
CODE:
{
STRLEN inlen, klen;
unsigned char *in;
unsigned char *k = (unsigned char *)SvPVbyte(key, klen);
int rv, i;
unsigned char mac[MAXBLOCKSIZE];
unsigned long len = sizeof(mac), outlen;
char out[MAXBLOCKSIZE*2];
blake2smac_state st;
if (size < len) len = size;
rv = blake2smac_init(&st, len, k, (unsigned long)klen);
if (rv != CRYPT_OK) croak("FATAL: blake2smac_init failed: %s", error_to_string(rv));
for (i = 2; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = blake2smac_process(&st, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: blake2smac_process failed: %s", error_to_string(rv));
}
}
rv = blake2smac_done(&st, mac, &len);
if (rv != CRYPT_OK) croak("FATAL: blake2smac_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 2) {
rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else {
RETVAL = newSVpvn((char *) mac, len);
}
}
OUTPUT:
RETVAL

View File

@ -1,157 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mac::F9
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mac::F9
new(Class, char * cipher_name, SV * key)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
int rv;
int id;
id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, f9_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = f9_init(RETVAL, id, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: f9_init failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mac::F9 self)
CODE:
Safefree(self);
Crypt::Mac::F9
clone(Crypt::Mac::F9 self)
CODE:
Newz(0, RETVAL, 1, f9_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, f9_state);
OUTPUT:
RETVAL
void
add(Crypt::Mac::F9 self, ...)
PPCODE:
{
int rv, i;
STRLEN in_data_len;
unsigned char *in_data;
for(i = 1; i < items; i++) {
in_data = (unsigned char *)SvPVbyte(ST(i), in_data_len);
if (in_data_len > 0) {
rv = f9_process(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: f9_process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
mac(Crypt::Mac::F9 self)
ALIAS:
hexmac = 1
b64mac = 2
b64umac = 3
CODE:
{
unsigned char mac[MAXBLOCKSIZE];
unsigned long maclen, outlen;
int rv;
char out[MAXBLOCKSIZE*2];
maclen = sizeof(mac);
rv = f9_done(self, mac, &maclen);
if (rv != CRYPT_OK) croak("FATAL: f9_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 2) {
rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 1) {
rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else {
RETVAL = newSVpvn((char * )mac, maclen);
}
}
OUTPUT:
RETVAL
SV *
f9(char * cipher_name, SV * key, ...)
ALIAS:
f9_hex = 1
f9_b64 = 2
f9_b64u = 3
CODE:
{
STRLEN inlen, klen;
unsigned char *in;
unsigned char *k = (unsigned char *)SvPVbyte(key, klen);
int rv, i;
unsigned char mac[MAXBLOCKSIZE];
unsigned long len = sizeof(mac), outlen;
char out[MAXBLOCKSIZE*2];
f9_state st;
int id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipher failed for '%s'", cipher_name);
rv = f9_init(&st, id, k, (unsigned long)klen);
if (rv != CRYPT_OK) croak("FATAL: f9_init failed: %s", error_to_string(rv));
for (i = 2; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = f9_process(&st, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: f9_process failed: %s", error_to_string(rv));
}
}
rv = f9_done(&st, mac, &len);
if (rv != CRYPT_OK) croak("FATAL: f9_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 2) {
rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else {
RETVAL = newSVpvn((char *) mac, len);
}
}
OUTPUT:
RETVAL

View File

@ -1,157 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mac::HMAC
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mac::HMAC
new(Class, char * hash_name, SV * key)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
int rv;
int id;
id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, hmac_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = hmac_init(RETVAL, id, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: hmac_init failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mac::HMAC self)
CODE:
Safefree(self);
Crypt::Mac::HMAC
clone(Crypt::Mac::HMAC self)
CODE:
Newz(0, RETVAL, 1, hmac_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, hmac_state);
OUTPUT:
RETVAL
void
add(Crypt::Mac::HMAC self, ...)
PPCODE:
{
int rv, i;
STRLEN in_data_len;
unsigned char *in_data;
for(i = 1; i < items; i++) {
in_data = (unsigned char *)SvPVbyte(ST(i), in_data_len);
if (in_data_len > 0) {
rv = hmac_process(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: hmac_process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
mac(Crypt::Mac::HMAC self)
ALIAS:
hexmac = 1
b64mac = 2
b64umac = 3
CODE:
{
unsigned char mac[MAXBLOCKSIZE];
unsigned long maclen, outlen;
int rv;
char out[MAXBLOCKSIZE*2];
maclen = sizeof(mac);
rv = hmac_done(self, mac, &maclen);
if (rv != CRYPT_OK) croak("FATAL: hmac_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 2) {
rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 1) {
rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else {
RETVAL = newSVpvn((char * )mac, maclen);
}
}
OUTPUT:
RETVAL
SV *
hmac(char * hash_name, SV * key, ...)
ALIAS:
hmac_hex = 1
hmac_b64 = 2
hmac_b64u = 3
CODE:
{
STRLEN inlen, klen;
unsigned char *in;
unsigned char *k = (unsigned char *)SvPVbyte(key, klen);
int rv, i;
unsigned char mac[MAXBLOCKSIZE];
unsigned long len = sizeof(mac), outlen;
char out[MAXBLOCKSIZE*2];
hmac_state st;
int id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_digest failed for '%s'", hash_name);
rv = hmac_init(&st, id, k, (unsigned long)klen);
if (rv != CRYPT_OK) croak("FATAL: hmac_init failed: %s", error_to_string(rv));
for (i = 2; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = hmac_process(&st, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: hmac_process failed: %s", error_to_string(rv));
}
}
rv = hmac_done(&st, mac, &len);
if (rv != CRYPT_OK) croak("FATAL: hmac_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 2) {
rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else {
RETVAL = newSVpvn((char *) mac, len);
}
}
OUTPUT:
RETVAL

View File

@ -1,157 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mac::OMAC
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mac::OMAC
new(Class, char * cipher_name, SV * key)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
int rv;
int id;
id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, omac_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = omac_init(RETVAL, id, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: omac_init failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mac::OMAC self)
CODE:
Safefree(self);
Crypt::Mac::OMAC
clone(Crypt::Mac::OMAC self)
CODE:
Newz(0, RETVAL, 1, omac_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, omac_state);
OUTPUT:
RETVAL
void
add(Crypt::Mac::OMAC self, ...)
PPCODE:
{
int rv, i;
STRLEN in_data_len;
unsigned char *in_data;
for(i = 1; i < items; i++) {
in_data = (unsigned char *)SvPVbyte(ST(i), in_data_len);
if (in_data_len > 0) {
rv = omac_process(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: omac_process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
mac(Crypt::Mac::OMAC self)
ALIAS:
hexmac = 1
b64mac = 2
b64umac = 3
CODE:
{
unsigned char mac[MAXBLOCKSIZE];
unsigned long maclen, outlen;
int rv;
char out[MAXBLOCKSIZE*2];
maclen = sizeof(mac);
rv = omac_done(self, mac, &maclen);
if (rv != CRYPT_OK) croak("FATAL: omac_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 2) {
rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 1) {
rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else {
RETVAL = newSVpvn((char * )mac, maclen);
}
}
OUTPUT:
RETVAL
SV *
omac(char * cipher_name, SV * key, ...)
ALIAS:
omac_hex = 1
omac_b64 = 2
omac_b64u = 3
CODE:
{
STRLEN inlen, klen;
unsigned char *in;
unsigned char *k = (unsigned char *)SvPVbyte(key, klen);
int rv, i;
unsigned char mac[MAXBLOCKSIZE];
unsigned long len = sizeof(mac), outlen;
char out[MAXBLOCKSIZE*2];
omac_state st;
int id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipher failed for '%s'", cipher_name);
rv = omac_init(&st, id, k, (unsigned long)klen);
if (rv != CRYPT_OK) croak("FATAL: omac_init failed: %s", error_to_string(rv));
for (i = 2; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = omac_process(&st, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: omac_process failed: %s", error_to_string(rv));
}
}
rv = omac_done(&st, mac, &len);
if (rv != CRYPT_OK) croak("FATAL: omac_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 2) {
rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else {
RETVAL = newSVpvn((char *) mac, len);
}
}
OUTPUT:
RETVAL

View File

@ -1,157 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mac::PMAC
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mac::PMAC
new(Class, char * cipher_name, SV * key)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
int rv;
int id;
id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, pmac_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = pmac_init(RETVAL, id, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: pmac_init failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mac::PMAC self)
CODE:
Safefree(self);
Crypt::Mac::PMAC
clone(Crypt::Mac::PMAC self)
CODE:
Newz(0, RETVAL, 1, pmac_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, pmac_state);
OUTPUT:
RETVAL
void
add(Crypt::Mac::PMAC self, ...)
PPCODE:
{
int rv, i;
STRLEN in_data_len;
unsigned char *in_data;
for(i = 1; i < items; i++) {
in_data = (unsigned char *)SvPVbyte(ST(i), in_data_len);
if (in_data_len > 0) {
rv = pmac_process(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: pmac_process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
mac(Crypt::Mac::PMAC self)
ALIAS:
hexmac = 1
b64mac = 2
b64umac = 3
CODE:
{
unsigned char mac[MAXBLOCKSIZE];
unsigned long maclen, outlen;
int rv;
char out[MAXBLOCKSIZE*2];
maclen = sizeof(mac);
rv = pmac_done(self, mac, &maclen);
if (rv != CRYPT_OK) croak("FATAL: pmac_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 2) {
rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 1) {
rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else {
RETVAL = newSVpvn((char * )mac, maclen);
}
}
OUTPUT:
RETVAL
SV *
pmac(char * cipher_name, SV * key, ...)
ALIAS:
pmac_hex = 1
pmac_b64 = 2
pmac_b64u = 3
CODE:
{
STRLEN inlen, klen;
unsigned char *in;
unsigned char *k = (unsigned char *)SvPVbyte(key, klen);
int rv, i;
unsigned char mac[MAXBLOCKSIZE];
unsigned long len = sizeof(mac), outlen;
char out[MAXBLOCKSIZE*2];
pmac_state st;
int id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipher failed for '%s'", cipher_name);
rv = pmac_init(&st, id, k, (unsigned long)klen);
if (rv != CRYPT_OK) croak("FATAL: pmac_init failed: %s", error_to_string(rv));
for (i = 2; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = pmac_process(&st, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: pmac_process failed: %s", error_to_string(rv));
}
}
rv = pmac_done(&st, mac, &len);
if (rv != CRYPT_OK) croak("FATAL: pmac_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 2) {
rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else {
RETVAL = newSVpvn((char *) mac, len);
}
}
OUTPUT:
RETVAL

View File

@ -1,152 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mac::Pelican
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mac::Pelican
new(Class, SV * key)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
int rv;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, pelican_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = pelican_init(RETVAL, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: pelican_init failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mac::Pelican self)
CODE:
Safefree(self);
Crypt::Mac::Pelican
clone(Crypt::Mac::Pelican self)
CODE:
Newz(0, RETVAL, 1, pelican_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, pelican_state);
OUTPUT:
RETVAL
void
add(Crypt::Mac::Pelican self, ...)
PPCODE:
{
int rv, i;
STRLEN in_data_len;
unsigned char *in_data;
for(i = 1; i < items; i++) {
in_data = (unsigned char *)SvPVbyte(ST(i), in_data_len);
if (in_data_len > 0) {
rv = pelican_process(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: pelican_process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
mac(Crypt::Mac::Pelican self)
ALIAS:
hexmac = 1
b64mac = 2
b64umac = 3
CODE:
{
unsigned char mac[MAXBLOCKSIZE];
unsigned long maclen, outlen;
int rv;
char out[MAXBLOCKSIZE*2];
maclen = 16;
rv = pelican_done(self, mac);
if (rv != CRYPT_OK) croak("FATAL: pelican_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 2) {
rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 1) {
rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else {
RETVAL = newSVpvn((char * )mac, maclen);
}
}
OUTPUT:
RETVAL
SV *
pelican(SV * key, ...)
ALIAS:
pelican_hex = 1
pelican_b64 = 2
pelican_b64u = 3
CODE:
{
STRLEN inlen, klen;
unsigned char *in;
unsigned char *k = (unsigned char *)SvPVbyte(key, klen);
int rv, i;
unsigned char mac[MAXBLOCKSIZE];
unsigned long len = sizeof(mac), outlen;
char out[MAXBLOCKSIZE*2];
pelican_state st;
len = 16;
rv = pelican_init(&st, k, (unsigned long)klen);
if (rv != CRYPT_OK) croak("FATAL: pelican_init failed: %s", error_to_string(rv));
for (i = 1; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = pelican_process(&st, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: pelican_process failed: %s", error_to_string(rv));
}
}
rv = pelican_done(&st, mac);
if (rv != CRYPT_OK) croak("FATAL: pelican_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 2) {
rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else {
RETVAL = newSVpvn((char *) mac, len);
}
}
OUTPUT:
RETVAL

View File

@ -1,151 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mac::Poly1305
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mac::Poly1305
new(Class, SV * key)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
int rv;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, poly1305_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = poly1305_init(RETVAL, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: poly1305_init failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mac::Poly1305 self)
CODE:
Safefree(self);
Crypt::Mac::Poly1305
clone(Crypt::Mac::Poly1305 self)
CODE:
Newz(0, RETVAL, 1, poly1305_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, poly1305_state);
OUTPUT:
RETVAL
void
add(Crypt::Mac::Poly1305 self, ...)
PPCODE:
{
int rv, i;
STRLEN in_data_len;
unsigned char *in_data;
for(i = 1; i < items; i++) {
in_data = (unsigned char *)SvPVbyte(ST(i), in_data_len);
if (in_data_len > 0) {
rv = poly1305_process(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: poly1305_process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
mac(Crypt::Mac::Poly1305 self)
ALIAS:
hexmac = 1
b64mac = 2
b64umac = 3
CODE:
{
unsigned char mac[MAXBLOCKSIZE];
unsigned long maclen, outlen;
int rv;
char out[MAXBLOCKSIZE*2];
maclen = sizeof(mac);
rv = poly1305_done(self, mac, &maclen);
if (rv != CRYPT_OK) croak("FATAL: poly1305_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 2) {
rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 1) {
rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else {
RETVAL = newSVpvn((char * )mac, maclen);
}
}
OUTPUT:
RETVAL
SV *
poly1305(SV * key, ...)
ALIAS:
poly1305_hex = 1
poly1305_b64 = 2
poly1305_b64u = 3
CODE:
{
STRLEN inlen, klen;
unsigned char *in;
unsigned char *k = (unsigned char *)SvPVbyte(key, klen);
int rv, i;
unsigned char mac[MAXBLOCKSIZE];
unsigned long len = sizeof(mac), outlen;
char out[MAXBLOCKSIZE*2];
poly1305_state st;
rv = poly1305_init(&st, k, (unsigned long)klen);
if (rv != CRYPT_OK) croak("FATAL: poly1305_init failed: %s", error_to_string(rv));
for (i = 1; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = poly1305_process(&st, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: poly1305_process failed: %s", error_to_string(rv));
}
}
rv = poly1305_done(&st, mac, &len);
if (rv != CRYPT_OK) croak("FATAL: poly1305_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 2) {
rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else {
RETVAL = newSVpvn((char *) mac, len);
}
}
OUTPUT:
RETVAL

View File

@ -1,157 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mac::XCBC
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mac::XCBC
new(Class, char * cipher_name, SV * key)
CODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
int rv;
int id;
id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, xcbc_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = xcbc_init(RETVAL, id, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: xcbc_init failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mac::XCBC self)
CODE:
Safefree(self);
Crypt::Mac::XCBC
clone(Crypt::Mac::XCBC self)
CODE:
Newz(0, RETVAL, 1, xcbc_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, xcbc_state);
OUTPUT:
RETVAL
void
add(Crypt::Mac::XCBC self, ...)
PPCODE:
{
int rv, i;
STRLEN in_data_len;
unsigned char *in_data;
for(i = 1; i < items; i++) {
in_data = (unsigned char *)SvPVbyte(ST(i), in_data_len);
if (in_data_len > 0) {
rv = xcbc_process(self, in_data, (unsigned long)in_data_len);
if (rv != CRYPT_OK) croak("FATAL: xcbc_process failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
SV *
mac(Crypt::Mac::XCBC self)
ALIAS:
hexmac = 1
b64mac = 2
b64umac = 3
CODE:
{
unsigned char mac[MAXBLOCKSIZE];
unsigned long maclen, outlen;
int rv;
char out[MAXBLOCKSIZE*2];
maclen = sizeof(mac);
rv = xcbc_done(self, mac, &maclen);
if (rv != CRYPT_OK) croak("FATAL: xcbc_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 2) {
rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
if (ix == 1) {
rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn(out, outlen);
}
else {
RETVAL = newSVpvn((char * )mac, maclen);
}
}
OUTPUT:
RETVAL
SV *
xcbc(char * cipher_name, SV * key, ...)
ALIAS:
xcbc_hex = 1
xcbc_b64 = 2
xcbc_b64u = 3
CODE:
{
STRLEN inlen, klen;
unsigned char *in;
unsigned char *k = (unsigned char *)SvPVbyte(key, klen);
int rv, i;
unsigned char mac[MAXBLOCKSIZE];
unsigned long len = sizeof(mac), outlen;
char out[MAXBLOCKSIZE*2];
xcbc_state st;
int id = _find_cipher(cipher_name);
if (id == -1) croak("FATAL: find_cipher failed for '%s'", cipher_name);
rv = xcbc_init(&st, id, k, (unsigned long)klen);
if (rv != CRYPT_OK) croak("FATAL: xcbc_init failed: %s", error_to_string(rv));
for (i = 2; i < items; i++) {
in = (unsigned char *)SvPVbyte(ST(i), inlen);
if (inlen > 0) {
rv = xcbc_process(&st, in, (unsigned long)inlen);
if (rv != CRYPT_OK) croak("FATAL: xcbc_process failed: %s", error_to_string(rv));
}
}
rv = xcbc_done(&st, mac, &len);
if (rv != CRYPT_OK) croak("FATAL: xcbc_done failed: %s", error_to_string(rv));
outlen = sizeof(out);
if (ix == 3) {
rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 2) {
rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else if (ix == 1) {
rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char *) out, outlen);
}
else {
RETVAL = newSVpvn((char *) mac, len);
}
}
OUTPUT:
RETVAL

View File

@ -1,267 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mode::CBC
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mode::CBC
new(Class, char * cipher_name, int padding=1, int rounds=0)
CODE:
{
Newz(0, RETVAL, 1, struct cbc_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->padding_mode = padding;
RETVAL->padlen = 0;
RETVAL->direction = 0;
RETVAL->cipher_rounds = rounds;
RETVAL->cipher_id = _find_cipher(cipher_name);
if (RETVAL->cipher_id == -1) {
Safefree(RETVAL);
croak("FATAL: find_cipfer failed for '%s'", cipher_name);
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mode::CBC self)
CODE:
Safefree(self);
void
start_decrypt(Crypt::Mode::CBC self, SV * key, SV * iv)
ALIAS:
start_encrypt = 1
PPCODE:
{
int rv;
STRLEN k_len=0;
unsigned char *k=NULL;
STRLEN i_len=0;
unsigned char *i=NULL;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
if (!SvPOK(iv)) croak("FATAL: iv must be string/buffer scalar");
i = (unsigned char *) SvPVbyte(iv, i_len);
if (i_len != (STRLEN)cipher_descriptor[self->cipher_id].block_length) {
croak ("FATAL: sizeof(iv) should be equal to blocksize (%d)", cipher_descriptor[self->cipher_id].block_length);
}
rv = cbc_start(self->cipher_id, i, k, (unsigned long)k_len, self->cipher_rounds, &self->state);
if (rv != CRYPT_OK) {
croak("FATAL: cbc_start failed: %s", error_to_string(rv));
}
self->direction = ix == 1 ? 1 : -1;
self->padlen = 0;
XPUSHs(ST(0)); /* return self */
}
SV *
add(Crypt::Mode::CBC self, ...)
CODE:
{
int rv, has_tmp_block, blen, j;
unsigned long i;
STRLEN in_data_len, in_data_start, out_len = 0;
unsigned char *in_data, *out_data, tmp_block[MAXBLOCKSIZE];
RETVAL = newSVpvn("", 0);
for (j = 1; j < items; j++) {
in_data = (unsigned char *)SvPVbyte(ST(j), in_data_len);
blen = (&self->state)->blocklen;
in_data_start = 0;
has_tmp_block = 0;
if (in_data_len > 0) {
if (self->direction == 1) {
/* handle non-empty self->pad buffer */
if (self->padlen > 0) {
i = (blen - self->padlen);
if (in_data_len >= i) { /* enough data to fill pad */
Copy(in_data, self->pad+self->padlen, i, unsigned char);
in_data_len -= i;
in_data_start = i;
rv = cbc_encrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: cbc_encrypt failed: %s", error_to_string(rv));
}
self->padlen = 0;
has_tmp_block = 1;
}
else { /* not enough data to fill pad */
Copy(in_data, self->pad+self->padlen, in_data_len, unsigned char);
self->padlen += (int)in_data_len;
in_data_len = 0;
}
}
i = (unsigned long)(in_data_len % blen);
if (in_data_len > 0 && i > 0) { /* save tail of data into pad */
Copy(in_data + in_data_start + in_data_len - i, self->pad, i, unsigned char);
self->padlen = i;
in_data_len -= i;
}
if (in_data_len > 0) {
i = (unsigned long)(has_tmp_block ? in_data_len + blen : in_data_len);
out_data = (unsigned char*)SvGROW(RETVAL, out_len + i + 1) + out_len;
out_len += i;
if (has_tmp_block) {
Copy(tmp_block, out_data, blen, unsigned char);
out_data += blen;
}
rv = cbc_encrypt(in_data+in_data_start, out_data, (unsigned long)in_data_len, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: cbc_encrypt failed: %s", error_to_string(rv));
}
} /* in_data_len > 0 */
else if (has_tmp_block) {
out_data = (unsigned char*)SvGROW(RETVAL, out_len + blen + 1) + out_len;
out_len += blen;
Copy(tmp_block, out_data, blen, unsigned char);
}
}
else if (self->direction == -1) {
if (self->padlen == blen) {
rv = cbc_decrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: cbc_decrypt failed: %s", error_to_string(rv));
}
self->padlen = 0;
has_tmp_block = 1;
} /* padlen == blen */
else if (self->padlen > 0) {
i = (blen - self->padlen); /* remaining bytes in padding buffer */
if (in_data_len >= i) { /* enough data to fill pad */
Copy(in_data, self->pad+self->padlen, i, unsigned char);
self->padlen += i;
in_data_len -= i;
in_data_start = i;
if (in_data_len>0 || self->padding_mode == 0) {
rv = cbc_decrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: cbc_decrypt failed: %s", error_to_string(rv));
}
self->padlen = 0;
has_tmp_block = 1;
}
}
else { /* not enough data to fill pad */
Copy(in_data, self->pad+self->padlen, in_data_len, unsigned char);
self->padlen += (int)in_data_len;
in_data_len = 0;
}
} /* padlen > 0 */
/* here: a/ padlen == 1..16 && in_data_len == 0; b/ padlen == 0 && in_data_len > 0 */
if (in_data_len>0) {
i = (unsigned long)(in_data_len % blen);
if (i>0) { /* save tail of data into pad */
Copy(in_data+in_data_start+in_data_len-i, self->pad, i, unsigned char);
self->padlen = i;
in_data_len -= i;
}
}
if (in_data_len>0) {
if (self->padlen == 0 && self->padding_mode !=0) {
/* in case of padding keep full pad if no more data */
Copy(in_data+in_data_start+in_data_len-blen, self->pad, blen, unsigned char);
self->padlen = blen;
in_data_len -= blen;
}
i = (unsigned long)(has_tmp_block ? in_data_len + blen : in_data_len);
if (i > 0) {
out_data = (unsigned char*)SvGROW(RETVAL, out_len + i + 1) + out_len;
out_len += i;
if (has_tmp_block) {
Copy(tmp_block, out_data, blen, unsigned char);
out_data += blen;
}
rv = cbc_decrypt(in_data+in_data_start, out_data, (unsigned long)in_data_len, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: cbc_decrypt failed: %s", error_to_string(rv));
}
}
} /* in_data_len>0 */
else if (has_tmp_block) {
out_data = (unsigned char*)SvGROW(RETVAL, out_len + blen + 1) + out_len;
out_len += blen;
Copy(tmp_block, out_data, blen, unsigned char);
}
}
else {
SvREFCNT_dec(RETVAL);
croak("FATAL: call start_decryt or start_encrpyt first (%d)", self->direction);
}
}
}
if (out_len > 0) SvCUR_set(RETVAL, out_len);
}
OUTPUT:
RETVAL
SV *
finish(Crypt::Mode::CBC self)
CODE:
{
unsigned char tmp_block[MAXBLOCKSIZE], ch;
int i, j, rv, blen = (&self->state)->blocklen;
if (self->direction == 1) {
if (self->padlen<0 || self->padlen>=blen) croak("FATAL: invalid padlen");
if (self->padding_mode == 1) { /* pkcs5|7 padding */
i = blen - self->padlen;
if (i == 0) i = blen;
for(j=self->padlen; j<blen; j++) self->pad[j] = (unsigned char)i;
rv = cbc_encrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) croak("FATAL: cbc_encrypt failed: %s", error_to_string(rv));
}
else if (self->padding_mode == 2) { /* oneandzeroes padding */
self->pad[self->padlen] = 0x80;
for(j=self->padlen+1; j<blen; j++) self->pad[j] = 0;
rv = cbc_encrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) croak("FATAL: cbc_encrypt failed: %s", error_to_string(rv));
}
else {
if (self->padlen>0) croak("FATAL: cbc_encrypt, input data length not multiple of %d", blen);
blen = 0;
}
}
else if (self->direction == -1) {
if (self->padlen > 0) {
if (self->padlen != blen) croak("FATAL: cipher text length has to be multiple of %d (%d)", blen, self->padlen);
rv = cbc_decrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) croak("FATAL: cbc_decrypt failed: %s", error_to_string(rv));
if (self->padding_mode == 0) { /* no padding */
/* we already have blen */
}
else if (self->padding_mode == 1) { /* pkcs5|7 padding */
ch = tmp_block[blen-1];
blen = blen - (ch > blen ? blen : ch);
}
else if (self->padding_mode == 2) { /* oneandzeroes padding */
while ((unsigned char)tmp_block[blen - 1] == 0x00) blen--;
if ((unsigned char)tmp_block[blen - 1] == 0x80) blen--;
if (blen < 0) blen = 0;
}
}
else {
blen = 0;
}
}
else {
XSRETURN_UNDEF;
}
self->direction = 0;
RETVAL = newSVpvn((char*)tmp_block, blen);
}
OUTPUT:
RETVAL

View File

@ -1,104 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mode::CFB
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mode::CFB
new(Class, char * cipher_name, int rounds=0)
CODE:
{
Newz(0, RETVAL, 1, struct cfb_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->direction = 0;
RETVAL->cipher_rounds = rounds;
RETVAL->cipher_id = _find_cipher(cipher_name);
if (RETVAL->cipher_id == -1) {
Safefree(RETVAL);
croak("FATAL: find_cipfer failed for '%s'", cipher_name);
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mode::CFB self)
CODE:
Safefree(self);
void
start_decrypt(Crypt::Mode::CFB self, SV * key, SV * iv)
ALIAS:
start_encrypt = 1
PPCODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
STRLEN i_len=0;
unsigned char *i=NULL;
int rv;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
if (!SvPOK(iv)) croak("FATAL: iv must be string/buffer scalar");
i = (unsigned char *) SvPVbyte(iv, i_len);
if (i_len != (STRLEN)cipher_descriptor[self->cipher_id].block_length) {
croak ("FATAL: sizeof(iv) should be equal to blocksize (%d)", cipher_descriptor[self->cipher_id].block_length);
}
rv = cfb_start(self->cipher_id, i, k, (int)k_len, self->cipher_rounds, &self->state);
if (rv != CRYPT_OK) {
croak("FATAL: cfb_start failed: %s", error_to_string(rv));
}
self->direction = ix == 1 ? 1 : -1;
XPUSHs(ST(0)); /* return self */
}
SV *
add(Crypt::Mode::CFB self, ...)
CODE:
{
int rv, j;
STRLEN in_data_len, out_len = 0;
unsigned char *in_data, *out_data;
RETVAL = newSVpvn("", 0);
for (j = 1; j < items; j++) {
in_data = (unsigned char *)SvPVbyte(ST(j), in_data_len);
if (in_data_len > 0) {
out_data = (unsigned char*)SvGROW(RETVAL, out_len + in_data_len + 1) + out_len;
out_len += in_data_len;
if (self->direction == 1) {
rv = cfb_encrypt(in_data, out_data, (unsigned long)in_data_len, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: cfb_encrypt failed: %s", error_to_string(rv));
}
}
else if (self->direction == -1) {
rv = cfb_decrypt(in_data, out_data, (unsigned long)in_data_len, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: cfb_decrypt failed: %s", error_to_string(rv));
}
}
else {
SvREFCNT_dec(RETVAL);
croak("FATAL: cfb_crypt failed: call start_encrypt or start_decrypt first");
}
}
}
if (out_len > 0) SvCUR_set(RETVAL, out_len);
}
OUTPUT:
RETVAL
SV *
finish(Crypt::Mode::CFB self)
CODE:
self->direction = 0;
RETVAL = newSVpvn("", 0);
OUTPUT:
RETVAL

View File

@ -1,109 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mode::CTR
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mode::CTR
new(Class, char * cipher_name, int ctr_mode=0, int ctr_width=0, int rounds=0)
CODE:
{
Newz(0, RETVAL, 1, struct ctr_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->direction = 0;
RETVAL->cipher_rounds = rounds;
RETVAL->cipher_id = _find_cipher(cipher_name);
if (RETVAL->cipher_id == -1) {
Safefree(RETVAL);
croak("FATAL: find_cipfer failed for '%s'", cipher_name);
}
if (ctr_mode == 0) RETVAL->ctr_mode_param = CTR_COUNTER_LITTLE_ENDIAN;
if (ctr_mode == 1) RETVAL->ctr_mode_param = CTR_COUNTER_BIG_ENDIAN;
if (ctr_mode == 2) RETVAL->ctr_mode_param = CTR_COUNTER_LITTLE_ENDIAN|LTC_CTR_RFC3686;
if (ctr_mode == 3) RETVAL->ctr_mode_param = CTR_COUNTER_BIG_ENDIAN|LTC_CTR_RFC3686;
if (ctr_width > 0 && ctr_width <= cipher_descriptor[RETVAL->cipher_id].block_length) RETVAL->ctr_mode_param |= ctr_width;
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mode::CTR self)
CODE:
Safefree(self);
void
start_decrypt(Crypt::Mode::CTR self, SV * key, SV * iv)
ALIAS:
start_encrypt = 1
PPCODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
STRLEN i_len=0;
unsigned char *i=NULL;
int rv;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
if (!SvPOK(iv)) croak("FATAL: iv must be string/buffer scalar");
i = (unsigned char *) SvPVbyte(iv, i_len);
if (i_len != (STRLEN)cipher_descriptor[self->cipher_id].block_length) {
croak ("FATAL: sizeof(iv) should be equal to blocksize (%d)", cipher_descriptor[self->cipher_id].block_length);
}
rv = ctr_start(self->cipher_id, i, k, (int)k_len, self->cipher_rounds, self->ctr_mode_param, &self->state);
if (rv != CRYPT_OK) {
croak("FATAL: ctr_start failed: %s", error_to_string(rv));
}
self->direction = ix == 1 ? 1 : -1;
XPUSHs(ST(0)); /* return self */
}
SV *
add(Crypt::Mode::CTR self, ...)
CODE:
{
int rv, j;
STRLEN in_data_len, out_len = 0;
unsigned char *in_data, *out_data;
RETVAL = newSVpvn("", 0);
for (j = 1; j < items; j++) {
in_data = (unsigned char *)SvPVbyte(ST(j), in_data_len);
if (in_data_len > 0) {
out_data = (unsigned char*)SvGROW(RETVAL, out_len + in_data_len + 1) + out_len;
out_len += in_data_len;
if (self->direction == 1) {
rv = ctr_encrypt(in_data, out_data, (unsigned long)in_data_len, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ctr_encrypt failed: %s", error_to_string(rv));
}
}
else if (self->direction == -1) {
rv = ctr_decrypt(in_data, out_data, (unsigned long)in_data_len, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ctr_decrypt failed: %s", error_to_string(rv));
}
}
else {
SvREFCNT_dec(RETVAL);
croak("FATAL: ctr_crypt failed: call start_encrypt or start_decrypt first");
}
}
}
if (out_len > 0) SvCUR_set(RETVAL, out_len);
}
OUTPUT:
RETVAL
SV *
finish(Crypt::Mode::CTR self)
CODE:
self->direction = 0;
RETVAL = newSVpvn("", 0);
OUTPUT:
RETVAL

View File

@ -1,260 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mode::ECB
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mode::ECB
new(Class, char * cipher_name, int padding=1, int rounds=0)
CODE:
{
Newz(0, RETVAL, 1, struct ecb_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->padding_mode = padding;
RETVAL->padlen = 0;
RETVAL->direction = 0;
RETVAL->cipher_rounds = rounds;
RETVAL->cipher_id = _find_cipher(cipher_name);
if (RETVAL->cipher_id == -1) {
Safefree(RETVAL);
croak("FATAL: find_cipfer failed for '%s'", cipher_name);
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mode::ECB self)
CODE:
Safefree(self);
void
start_decrypt(Crypt::Mode::ECB self, SV * key)
ALIAS:
start_encrypt = 1
PPCODE:
{
int rv;
STRLEN k_len=0;
unsigned char *k=NULL;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
rv = ecb_start(self->cipher_id, k, (unsigned long)k_len, self->cipher_rounds, &self->state);
if (rv != CRYPT_OK) {
croak("FATAL: ecb_start failed: %s", error_to_string(rv));
}
self->direction = ix == 1 ? 1 : -1;
self->padlen = 0;
XPUSHs(ST(0)); /* return self */
}
SV *
add(Crypt::Mode::ECB self, ...)
CODE:
{
int rv, has_tmp_block, blen, j;
unsigned long i;
STRLEN in_data_len, in_data_start, out_len = 0;
unsigned char *in_data, *out_data, tmp_block[MAXBLOCKSIZE];
RETVAL = newSVpvn("", 0);
for (j = 1; j < items; j++) {
in_data = (unsigned char *)SvPVbyte(ST(j), in_data_len);
blen = (&self->state)->blocklen;
in_data_start = 0;
has_tmp_block = 0;
if (in_data_len > 0) {
if (self->direction == 1) {
/* handle non-empty self->pad buffer */
if (self->padlen > 0) {
i = (blen - self->padlen);
if (in_data_len >= i) { /* enough data to fill pad */
Copy(in_data, self->pad+self->padlen, i, unsigned char);
in_data_len -= i;
in_data_start = i;
rv = ecb_encrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ecb_encrypt failed: %s", error_to_string(rv));
}
self->padlen = 0;
has_tmp_block = 1;
}
else { /* not enough data to fill pad */
Copy(in_data, self->pad+self->padlen, in_data_len, unsigned char);
self->padlen += (int)in_data_len;
in_data_len = 0;
}
}
i = (unsigned long)(in_data_len % blen);
if (in_data_len > 0 && i > 0) { /* save tail of data into pad */
Copy(in_data + in_data_start + in_data_len - i, self->pad, i, unsigned char);
self->padlen = i;
in_data_len -= i;
}
if (in_data_len > 0) {
i = (unsigned long)(has_tmp_block ? in_data_len + blen : in_data_len);
out_data = (unsigned char*)SvGROW(RETVAL, out_len + i + 1) + out_len;
out_len += i;
if (has_tmp_block) {
Copy(tmp_block, out_data, blen, unsigned char);
out_data += blen;
}
rv = ecb_encrypt(in_data+in_data_start, out_data, (unsigned long)in_data_len, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ecb_encrypt failed: %s", error_to_string(rv));
}
} /* in_data_len > 0 */
else if (has_tmp_block) {
out_data = (unsigned char*)SvGROW(RETVAL, out_len + blen + 1) + out_len;
out_len += blen;
Copy(tmp_block, out_data, blen, unsigned char);
}
}
else if (self->direction == -1) {
if (self->padlen == blen) {
rv = ecb_decrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ecb_decrypt failed: %s", error_to_string(rv));
}
self->padlen = 0;
has_tmp_block = 1;
} /* padlen == blen */
else if (self->padlen > 0) {
i = (blen - self->padlen); /* remaining bytes in padding buffer */
if (in_data_len >= i) { /* enough data to fill pad */
Copy(in_data, self->pad+self->padlen, i, unsigned char);
self->padlen += i;
in_data_len -= i;
in_data_start = i;
if (in_data_len>0 || self->padding_mode == 0) {
rv = ecb_decrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ecb_decrypt failed: %s", error_to_string(rv));
}
self->padlen = 0;
has_tmp_block = 1;
}
}
else { /* not enough data to fill pad */
Copy(in_data, self->pad+self->padlen, in_data_len, unsigned char);
self->padlen += (int)in_data_len;
in_data_len = 0;
}
} /* padlen > 0 */
/* here: a/ padlen == 1..16 && in_data_len == 0; b/ padlen == 0 && in_data_len > 0 */
if (in_data_len>0) {
i = (unsigned long)(in_data_len % blen);
if (i>0) { /* save tail of data into pad */
Copy(in_data+in_data_start+in_data_len-i, self->pad, i, unsigned char);
self->padlen = i;
in_data_len -= i;
}
}
if (in_data_len>0) {
if (self->padlen == 0 && self->padding_mode !=0) {
/* in case of padding keep full pad if no more data */
Copy(in_data+in_data_start+in_data_len-blen, self->pad, blen, unsigned char);
self->padlen = blen;
in_data_len -= blen;
}
i = (unsigned long)(has_tmp_block ? in_data_len + blen : in_data_len);
if (i > 0) {
out_data = (unsigned char*)SvGROW(RETVAL, out_len + i + 1) + out_len;
out_len += i;
if (has_tmp_block) {
Copy(tmp_block, out_data, blen, unsigned char);
out_data += blen;
}
rv = ecb_decrypt(in_data+in_data_start, out_data, (unsigned long)in_data_len, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ecb_decrypt failed: %s", error_to_string(rv));
}
}
} /* in_data_len>0 */
else if (has_tmp_block) {
out_data = (unsigned char*)SvGROW(RETVAL, out_len + blen + 1) + out_len;
out_len += blen;
Copy(tmp_block, out_data, blen, unsigned char);
}
}
else {
SvREFCNT_dec(RETVAL);
croak("FATAL: call start_decryt or start_encrpyt first (%d)", self->direction);
}
}
}
if (out_len > 0) SvCUR_set(RETVAL, out_len);
}
OUTPUT:
RETVAL
SV *
finish(Crypt::Mode::ECB self)
CODE:
{
unsigned char tmp_block[MAXBLOCKSIZE], ch;
int i, j, rv, blen = (&self->state)->blocklen;
if (self->direction == 1) {
if (self->padlen<0 || self->padlen>=blen) croak("FATAL: invalid padlen");
if (self->padding_mode == 1) { /* pkcs5|7 padding */
i = blen - self->padlen;
if (i == 0) i = blen;
for(j=self->padlen; j<blen; j++) self->pad[j] = (unsigned char)i;
rv = ecb_encrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) croak("FATAL: ecb_encrypt failed: %s", error_to_string(rv));
}
else if (self->padding_mode == 2) { /* oneandzeroes padding */
self->pad[self->padlen] = 0x80;
for(j=self->padlen+1; j<blen; j++) self->pad[j] = 0;
rv = ecb_encrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) croak("FATAL: ecb_encrypt failed: %s", error_to_string(rv));
}
else {
if (self->padlen>0) croak("FATAL: ecb_encrypt, input data length not multiple of %d", blen);
blen = 0;
}
}
else if (self->direction == -1) {
if (self->padlen > 0) {
if (self->padlen != blen) croak("FATAL: cipher text length has to be multiple of %d (%d)", blen, self->padlen);
rv = ecb_decrypt(self->pad, tmp_block, blen, &self->state);
if (rv != CRYPT_OK) croak("FATAL: ecb_decrypt failed: %s", error_to_string(rv));
if (self->padding_mode == 0) { /* no padding */
/* we already have blen */
}
else if (self->padding_mode == 1) { /* pkcs5|7 padding */
ch = tmp_block[blen-1];
blen = blen - (ch > blen ? blen : ch);
}
else if (self->padding_mode == 2) { /* oneandzeroes padding */
while ((unsigned char)tmp_block[blen - 1] == 0x00) blen--;
if ((unsigned char)tmp_block[blen - 1] == 0x80) blen--;
if (blen < 0) blen = 0;
}
}
else {
blen = 0;
}
}
else {
XSRETURN_UNDEF;
}
self->direction = 0;
RETVAL = newSVpvn((char*)tmp_block, blen);
}
OUTPUT:
RETVAL

View File

@ -1,104 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Mode::OFB
PROTOTYPES: DISABLE
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
Crypt::Mode::OFB
new(Class, char * cipher_name, int rounds=0)
CODE:
{
Newz(0, RETVAL, 1, struct ofb_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->direction = 0;
RETVAL->cipher_rounds = rounds;
RETVAL->cipher_id = _find_cipher(cipher_name);
if (RETVAL->cipher_id == -1) {
Safefree(RETVAL);
croak("FATAL: find_cipfer failed for '%s'", cipher_name);
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Mode::OFB self)
CODE:
Safefree(self);
void
start_decrypt(Crypt::Mode::OFB self, SV * key, SV * iv)
ALIAS:
start_encrypt = 1
PPCODE:
{
STRLEN k_len=0;
unsigned char *k=NULL;
STRLEN i_len=0;
unsigned char *i=NULL;
int rv;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
if (!SvPOK(iv)) croak("FATAL: iv must be string/buffer scalar");
i = (unsigned char *) SvPVbyte(iv, i_len);
if (i_len != (STRLEN)cipher_descriptor[self->cipher_id].block_length) {
croak ("FATAL: sizeof(iv) should be equal to blocksize (%d)", cipher_descriptor[self->cipher_id].block_length);
}
rv = ofb_start(self->cipher_id, i, k, (int)k_len, self->cipher_rounds, &self->state);
if (rv != CRYPT_OK) {
croak("FATAL: ofb_start failed: %s", error_to_string(rv));
}
self->direction = ix == 1 ? 1 : -1;
XPUSHs(ST(0)); /* return self */
}
SV *
add(Crypt::Mode::OFB self, ...)
CODE:
{
int rv, j;
STRLEN in_data_len, out_len = 0;
unsigned char *in_data, *out_data;
RETVAL = newSVpvn("", 0);
for (j = 1; j < items; j++) {
in_data = (unsigned char *)SvPVbyte(ST(j), in_data_len);
if (in_data_len > 0) {
out_data = (unsigned char*)SvGROW(RETVAL, out_len + in_data_len + 1) + out_len;
out_len += in_data_len;
if (self->direction == 1) {
rv = ofb_encrypt(in_data, out_data, (unsigned long)in_data_len, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ofb_encrypt failed: %s", error_to_string(rv));
}
}
else if (self->direction == -1) {
rv = ofb_decrypt(in_data, out_data, (unsigned long)in_data_len, &self->state);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: ofb_decrypt failed: %s", error_to_string(rv));
}
}
else {
SvREFCNT_dec(RETVAL);
croak("FATAL: ofb_crypt failed: call start_encrypt or start_decrypt first");
}
}
}
if (out_len > 0) SvCUR_set(RETVAL, out_len);
}
OUTPUT:
RETVAL
SV *
finish(Crypt::Mode::OFB self)
CODE:
self->direction = 0;
RETVAL = newSVpvn("", 0);
OUTPUT:
RETVAL

View File

@ -1,329 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::PK::DH
PROTOTYPES: DISABLE
Crypt::PK::DH
_new(Class)
CODE:
{
int rv;
Newz(0, RETVAL, 1, struct dh_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->key.type = -1;
RETVAL->pindex = find_prng("chacha20");
if (RETVAL->pindex == -1) {
Safefree(RETVAL);
croak("FATAL: find_prng('chacha20') failed");
}
rv = rng_make_prng(320, RETVAL->pindex, &RETVAL->pstate, NULL); /* 320bits = 40bytes */
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: rng_make_prng failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
_generate_key_size(Crypt::PK::DH self, int groupsize=256)
PPCODE:
{
int rv;
rv = dh_set_pg_groupsize(groupsize, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_set_pg_groupsize failed: %s", error_to_string(rv));
rv = dh_generate_key(&self->pstate, self->pindex, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_generate_key failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_generate_key_gp(Crypt::PK::DH self, char *g, char *p)
PPCODE:
{
int rv;
unsigned char pbin[1024], gbin[512];
unsigned long plen=sizeof(pbin), glen=sizeof(gbin);
if (p && strlen(p) > 0 && g && strlen(g) > 0) {
rv = radix_to_bin(p, 16, pbin, &plen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
rv = radix_to_bin(g, 16, gbin, &glen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(g) failed: %s", error_to_string(rv));
rv = dh_set_pg(pbin, plen, gbin, glen, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_set_pg failed: %s", error_to_string(rv));
rv = dh_generate_key(&self->pstate, self->pindex, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_generate_key failed: %s", error_to_string(rv));
}
XPUSHs(ST(0)); /* return self */
}
void
_generate_key_dhparam(Crypt::PK::DH self, SV * dhparam)
PPCODE:
{
int rv;
unsigned char *data=NULL;
STRLEN data_len=0;
data = (unsigned char *)SvPVbyte(dhparam, data_len);
/* load d p q */
rv = dh_set_pg_dhparam(data, (unsigned long)data_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_set_pg_dhparam failed: %s", error_to_string(rv));
/* gen the key */
rv = dh_generate_key(&self->pstate, self->pindex, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_generate_key failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import(Crypt::PK::DH self, SV * key_data)
PPCODE:
{
int rv;
unsigned char *data=NULL;
STRLEN data_len=0;
data = (unsigned char *)SvPVbyte(key_data, data_len);
if (self->key.type != -1) { dh_free(&self->key); self->key.type = -1; }
rv = dh_import(data, (unsigned long)data_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_import failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import_raw(Crypt::PK::DH self, SV * raw_key, int type, char * g, char * p)
PPCODE:
{
int rv;
unsigned char *data=NULL;
STRLEN data_len=0;
unsigned char pbin[1024], gbin[512];
unsigned long plen=sizeof(pbin), glen=sizeof(gbin);
data = (unsigned char *)SvPVbyte(raw_key, data_len);
if (self->key.type != -1) { dh_free(&self->key); self->key.type = -1; }
if (p && strlen(p) > 0 && g && strlen(g) > 0) {
rv = radix_to_bin(p, 16, pbin, &plen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
rv = radix_to_bin(g, 16, gbin, &glen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(g) failed: %s", error_to_string(rv));
rv = dh_set_pg(pbin, plen, gbin, glen, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_set_pg failed: %s", error_to_string(rv));
if (type == 0) {
/* public */
rv = dh_set_key(data, (unsigned long)data_len, PK_PUBLIC, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_set_key failed: %s", error_to_string(rv));
}
else if (type == 1) {
/* private */
rv = dh_set_key(data, (unsigned long)data_len, PK_PRIVATE, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_set_key failed: %s", error_to_string(rv));
}
else {
croak("FATAL: import_raw invalid type '%d'", type);
}
}
XPUSHs(ST(0)); /* return self */
}
int
is_private(Crypt::PK::DH self)
CODE:
if (self->key.type == -1) XSRETURN_UNDEF;
RETVAL = (self->key.type == PK_PRIVATE) ? 1 : 0;
OUTPUT:
RETVAL
int
size(Crypt::PK::DH self)
CODE:
if (self->key.type == -1) XSRETURN_UNDEF;
RETVAL = dh_get_groupsize(&self->key);
OUTPUT:
RETVAL
SV*
key2hash(Crypt::PK::DH self)
PREINIT:
HV *rv_hash;
long siz;
char buf[20001];
SV **not_used;
CODE:
if (self->key.type == -1) XSRETURN_UNDEF;
rv_hash = newHV();
/* x */
siz = (self->key.x) ? mp_unsigned_bin_size(self->key.x) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'x' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.x, buf, 20000, 0);
not_used = hv_store(rv_hash, "x", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "x", 1, newSVpv("", 0), 0);
}
/* y */
siz = (self->key.y) ? mp_unsigned_bin_size(self->key.y) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'y' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.y, buf, 20000, 0);
not_used = hv_store(rv_hash, "y", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "y", 1, newSVpv("", 0), 0);
}
/* p */
siz = (self->key.prime) ? mp_unsigned_bin_size(self->key.prime) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'p' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.prime, buf, 20000, 0);
not_used = hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0);
}
else {
not_used = hv_store(rv_hash, "p", 1, newSVpv("", 0), 0);
}
/* g */
siz = (self->key.base) ? mp_unsigned_bin_size(self->key.base) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'g' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.base, buf, 20000, 0);
not_used = hv_store(rv_hash, "g", 1, newSVpv(buf, strlen(buf)), 0);
}
else {
not_used = hv_store(rv_hash, "g", 1, newSVpv("", 0), 0);
}
/* size */
not_used = hv_store(rv_hash, "size", 4, newSViv(dh_get_groupsize(&self->key)), 0);
/* type */
not_used = hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0);
LTC_UNUSED_PARAM(not_used);
RETVAL = newRV_noinc((SV*)rv_hash);
OUTPUT:
RETVAL
SV*
params2hash(Crypt::PK::DH self)
PREINIT:
HV *rv_hash;
long siz;
char buf[20001];
SV **not_used;
CODE:
if (self->key.type == -1) XSRETURN_UNDEF;
rv_hash = newHV();
/* p */
siz = (self->key.prime) ? mp_unsigned_bin_size(self->key.prime) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'p' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.prime, buf, 20000, 0);
not_used = hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0);
}
else {
not_used = hv_store(rv_hash, "p", 1, newSVpv("", 0), 0);
}
/* g */
siz = (self->key.base) ? mp_unsigned_bin_size(self->key.base) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'g' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.base, buf, 20000, 0);
not_used = hv_store(rv_hash, "g", 1, newSVpv(buf, strlen(buf)), 0);
}
else {
not_used = hv_store(rv_hash, "g", 1, newSVpv("", 0), 0);
}
if (not_used) not_used = NULL; /* just silence the warning: variable 'not_used' set but not used */
RETVAL = newRV_noinc((SV*)rv_hash);
OUTPUT:
RETVAL
SV *
export_key(Crypt::PK::DH self, char * type)
CODE:
{
int rv;
unsigned long int out_len = 4096;
unsigned char out[4096];
RETVAL = newSVpvn(NULL, 0); /* undef */
if (strnEQ(type, "private", 7)) {
rv = dh_export(out, &out_len, PK_PRIVATE, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_export(PK_PRIVATE) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "public", 6)) {
rv = dh_export(out, &out_len, PK_PUBLIC, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_export(PK_PUBLIC) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else {
croak("FATAL: export_key_der invalid type '%s'", type);
}
}
OUTPUT:
RETVAL
SV *
shared_secret(Crypt::PK::DH self, Crypt::PK::DH pubkey)
CODE:
{
int rv;
unsigned long buffer_len = 1024;
unsigned char buffer[1024];
rv = dh_shared_secret(&self->key, &pubkey->key, buffer, &buffer_len);
if (rv != CRYPT_OK) croak("FATAL: dh_shared_secret failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
OUTPUT:
RETVAL
SV *
export_key_raw(Crypt::PK::DH self, char * type)
CODE:
{
int rv;
unsigned char out[1024];
unsigned long out_len = 1024;
RETVAL = newSVpvn(NULL, 0); /* undef */
if (strnEQ(type, "private", 7)) {
rv = dh_export_key(out, &out_len, PK_PRIVATE, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_export_key(PK_PRIVATE) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "public", 6)) {
rv = dh_export_key(out, &out_len, PK_PUBLIC, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dh_export_key(PK_PUBLIC) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else {
croak("FATAL: export_key_raw: invalid type '%s'", type);
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::PK::DH self)
CODE:
if (self->key.type != -1) { dh_free(&self->key); self->key.type = -1; }
Safefree(self);

View File

@ -1,370 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::PK::DSA
PROTOTYPES: DISABLE
Crypt::PK::DSA
_new(Class)
CODE:
{
int rv;
Newz(0, RETVAL, 1, struct dsa_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->key.type = -1;
RETVAL->pindex = find_prng("chacha20");
if (RETVAL->pindex == -1) {
Safefree(RETVAL);
croak("FATAL: find_prng('chacha20') failed");
}
rv = rng_make_prng(320, RETVAL->pindex, &RETVAL->pstate, NULL); /* 320bits = 40bytes */
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: rng_make_prng failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
_generate_key_size(Crypt::PK::DSA self, int group_size=30, int modulus_size=256)
PPCODE:
{
int rv;
/* gen the key */
rv = dsa_make_key(&self->pstate, self->pindex, group_size, modulus_size, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_make_key failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_generate_key_dsaparam(Crypt::PK::DSA self, SV * dsaparam)
PPCODE:
{
int rv;
unsigned char *data=NULL;
STRLEN data_len=0;
data = (unsigned char *)SvPVbyte(dsaparam, data_len);
/* load d p q */
rv = dsa_set_pqg_dsaparam(data, (unsigned long)data_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_set_pqg_dsaparam failed: %s", error_to_string(rv));
/* gen the key */
rv = dsa_generate_key(&self->pstate, self->pindex, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_generate_key failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_generate_key_pqg_hex(Crypt::PK::DSA self, char *p, char *q, char *g)
PPCODE:
{
int rv;
unsigned char pbin[512], qbin[512], gbin[512];
unsigned long plen=sizeof(pbin), qlen=sizeof(qbin), glen=sizeof(gbin);
if (!p || !strlen(p) || !q || !strlen(q) || !g || !strlen(g)) {
croak("FATAL: generate_key_pqg_hex incomplete args");
}
/* set p q g */
rv = radix_to_bin(p, 16, pbin, &plen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
rv = radix_to_bin(q, 16, qbin, &qlen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(q) failed: %s", error_to_string(rv));
rv = radix_to_bin(g, 16, gbin, &glen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(g) failed: %s", error_to_string(rv));
rv = dsa_set_pqg(pbin, plen, qbin, qlen, gbin, glen, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_set_pqg failed: %s", error_to_string(rv));
/* gen the key */
rv = dsa_generate_key(&self->pstate, self->pindex, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_generate_key failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import(Crypt::PK::DSA self, SV * key_data)
PPCODE:
{
int rv;
unsigned char *data=NULL;
STRLEN data_len=0;
data = (unsigned char *)SvPVbyte(key_data, data_len);
if (self->key.type != -1) { dsa_free(&self->key); self->key.type = -1; }
rv = dsa_import(data, (unsigned long)data_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_import failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import_hex(Crypt::PK::DSA self, char *p, char *q, char *g, char *x, char *y)
PPCODE:
{
int rv;
unsigned char pbin[512], qbin[512], gbin[512], xbin[512], ybin[512];
unsigned long plen=sizeof(pbin), qlen=sizeof(qbin), glen=sizeof(gbin), xlen=sizeof(xbin), ylen=sizeof(ybin);
if (self->key.type != -1) { dsa_free(&self->key); self->key.type = -1; }
if (p && strlen(p) > 0 && q && strlen(q) > 0 && g && strlen(g) > 0 && y && strlen(y) > 0) {
rv = radix_to_bin(p, 16, pbin, &plen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
rv = radix_to_bin(q, 16, qbin, &qlen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(q) failed: %s", error_to_string(rv));
rv = radix_to_bin(g, 16, gbin, &glen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(g) failed: %s", error_to_string(rv));
rv = dsa_set_pqg(pbin, plen, qbin, qlen, gbin, glen, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_set_pqg failed: %s", error_to_string(rv));
rv = radix_to_bin(y, 16, ybin, &ylen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(y) failed: %s", error_to_string(rv));
if (x && strlen(x) > 0) {
/* private */
rv = radix_to_bin(x, 16, xbin, &xlen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(x) failed: %s", error_to_string(rv));
rv = dsa_set_key(xbin, xlen, PK_PRIVATE, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_set_key failed: %s", error_to_string(rv));
}
else {
/* public */
rv = dsa_set_key(ybin, ylen, PK_PUBLIC, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_set_key failed: %s", error_to_string(rv));
}
}
XPUSHs(ST(0)); /* return self */
}
int
is_private(Crypt::PK::DSA self)
CODE:
if (self->key.type == -1 || self->key.qord <= 0) XSRETURN_UNDEF;
RETVAL = (self->key.type == PK_PRIVATE) ? 1 : 0;
OUTPUT:
RETVAL
int
size(Crypt::PK::DSA self)
CODE:
if (self->key.type == -1 || self->key.qord <= 0) XSRETURN_UNDEF;
RETVAL = mp_unsigned_bin_size(self->key.p);
OUTPUT:
RETVAL
int
size_q(Crypt::PK::DSA self)
CODE:
if (self->key.type == -1 || self->key.qord <= 0) XSRETURN_UNDEF;
RETVAL = mp_unsigned_bin_size(self->key.q);
OUTPUT:
RETVAL
SV*
key2hash(Crypt::PK::DSA self)
PREINIT:
HV *rv_hash;
long siz, qsize, psize;
char buf[20001];
SV **not_used;
CODE:
if (self->key.type == -1 || self->key.qord <= 0) XSRETURN_UNDEF;
qsize = mp_unsigned_bin_size(self->key.q);
psize = mp_unsigned_bin_size(self->key.p);
rv_hash = newHV();
/* g */
siz = (self->key.g) ? mp_unsigned_bin_size(self->key.g) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'g' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.g, buf, 20000, 0);
not_used = hv_store(rv_hash, "g", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "g", 1, newSVpv("", 0), 0);
}
/* q */
siz = (self->key.q) ? mp_unsigned_bin_size(self->key.q) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'q' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.q, buf, 20000, 0);
not_used = hv_store(rv_hash, "q", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "q", 1, newSVpv("", 0), 0);
}
/* p */
siz = (self->key.p) ? mp_unsigned_bin_size(self->key.p) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'p' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.p, buf, 20000, 0);
not_used = hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "p", 1, newSVpv("", 0), 0);
}
/* x */
siz = (self->key.x) ? mp_unsigned_bin_size(self->key.x) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'x' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.x, buf, 20000, qsize*2);
not_used = hv_store(rv_hash, "x", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "x", 1, newSVpv("", 0), 0);
}
/* y */
siz = (self->key.y) ? mp_unsigned_bin_size(self->key.y) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'y' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.y, buf, 20000, psize*2);
not_used = hv_store(rv_hash, "y", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "y", 1, newSVpv("", 0), 0);
}
/* size */
not_used = hv_store(rv_hash, "size", 4, newSViv(qsize), 0);
/* type */
not_used = hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0);
LTC_UNUSED_PARAM(not_used);
RETVAL = newRV_noinc((SV*)rv_hash);
OUTPUT:
RETVAL
SV *
export_key_der(Crypt::PK::DSA self, char * type)
CODE:
{
int rv;
unsigned char out[4096];
unsigned long int out_len = 4096;
RETVAL = newSVpvn(NULL, 0); /* undef */
if (strnEQ(type, "private", 7)) {
rv = dsa_export(out, &out_len, PK_PRIVATE|PK_STD, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_export(PK_PRIVATE|PK_STD) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "public", 6)) {
rv = dsa_export(out, &out_len, PK_PUBLIC|PK_STD, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_export(PK_PUBLIC|PK_STD) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else {
croak("FATAL: export_key_der invalid type '%s'", type);
}
}
OUTPUT:
RETVAL
SV *
encrypt(Crypt::PK::DSA self, SV * data, const char * hash_name = "SHA1")
CODE:
{
int rv, hash_id;
unsigned char *data_ptr=NULL;
STRLEN data_len=0;
unsigned char buffer[1024];
unsigned long buffer_len = 1024;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
hash_id = _find_hash(hash_name);
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = dsa_encrypt_key(data_ptr, (unsigned long)data_len, buffer, &buffer_len,
&self->pstate, self->pindex,
hash_id, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_encrypt_key failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
OUTPUT:
RETVAL
SV *
decrypt(Crypt::PK::DSA self, SV * data)
CODE:
{
int rv;
unsigned char *data_ptr=NULL;
STRLEN data_len=0;
unsigned char buffer[1024];
unsigned long buffer_len = 1024;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
rv = dsa_decrypt_key(data_ptr, (unsigned long)data_len, buffer, &buffer_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_decrypt_key_ex failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
OUTPUT:
RETVAL
SV *
sign_hash(Crypt::PK::DSA self, SV * data, const char * hash_name = "SHA1")
ALIAS:
sign_message = 1
CODE:
{
int rv, id;
unsigned char buffer[1024], tmp[MAXBLOCKSIZE], *data_ptr = NULL;
unsigned long tmp_len = MAXBLOCKSIZE, buffer_len = 1024;
STRLEN data_len = 0;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
if (ix == 1) {
id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = hash_memory(id, data_ptr, (unsigned long)data_len, tmp, &tmp_len);
if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv));
data_ptr = tmp;
data_len = tmp_len;
}
rv = dsa_sign_hash(data_ptr, (unsigned long)data_len, buffer, &buffer_len,
&self->pstate, self->pindex,
&self->key);
if (rv != CRYPT_OK) croak("FATAL: dsa_sign_hash_ex failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
OUTPUT:
RETVAL
int
verify_hash(Crypt::PK::DSA self, SV * sig, SV * data, const char * hash_name = "SHA1")
ALIAS:
verify_message = 1
CODE:
{
int rv, stat, id;
unsigned char tmp[MAXBLOCKSIZE], *data_ptr = NULL, *sig_ptr = NULL;
unsigned long tmp_len = MAXBLOCKSIZE;
STRLEN data_len = 0, sig_len = 0;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
sig_ptr = (unsigned char *)SvPVbyte(sig, sig_len);
if (ix == 1) {
id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = hash_memory(id, data_ptr, (unsigned long)data_len, tmp, &tmp_len);
if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv));
data_ptr = tmp;
data_len = tmp_len;
}
RETVAL = 1;
stat = 0;
rv = dsa_verify_hash(sig_ptr, (unsigned long)sig_len, data_ptr, (unsigned long)data_len, &stat, &self->key);
if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::PK::DSA self)
CODE:
if (self->key.type != -1) { dsa_free(&self->key); self->key.type = -1; }
Safefree(self);

View File

@ -1,439 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::PK::ECC
PROTOTYPES: DISABLE
Crypt::PK::ECC
_new(Class)
CODE:
{
int rv;
Newz(0, RETVAL, 1, struct ecc_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->pindex = find_prng("chacha20");
RETVAL->key.type = -1;
if (RETVAL->pindex == -1) {
Safefree(RETVAL);
croak("FATAL: find_prng('chacha20') failed");
}
rv = rng_make_prng(320, RETVAL->pindex, &RETVAL->pstate, NULL); /* 320bits = 40bytes */
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: rng_make_prng failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
generate_key(Crypt::PK::ECC self, SV *curve)
PPCODE:
{
int rv;
/* setup dp structure */
rv = _ecc_set_dp_from_SV(&self->key, curve); /* croaks on error */
if (rv != CRYPT_OK) croak("FATAL: ecc_set_dp failed: %s", error_to_string(rv));
/* gen the key */
rv = ecc_generate_key(&self->pstate, self->pindex, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_generate_key failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import(Crypt::PK::ECC self, SV * key_data)
PPCODE:
{
int rv;
unsigned char *data=NULL;
STRLEN data_len=0;
data = (unsigned char *)SvPVbyte(key_data, data_len);
if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
rv = ecc_import_openssl(data, (unsigned long)data_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_import_openssl failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import_pkcs8(Crypt::PK::ECC self, SV * key_data, SV * passwd)
PPCODE:
{
int rv;
unsigned char *data=NULL, *pwd=NULL;
STRLEN data_len=0, pwd_len=0;
data = (unsigned char *)SvPVbyte(key_data, data_len);
if (SvOK(passwd)) {
pwd = (unsigned char *)SvPVbyte(passwd, pwd_len);
}
if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
rv = ecc_import_pkcs8(data, (unsigned long)data_len, pwd, (unsigned long)pwd_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_import_pkcs8 failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import_x509(Crypt::PK::ECC self, SV * key_data)
PPCODE:
{
int rv;
unsigned char *data=NULL;
STRLEN data_len=0;
data = (unsigned char *)SvPVbyte(key_data, data_len);
if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
rv = ecc_import_x509(data, (unsigned long)data_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_import_x509 failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
import_key_raw(Crypt::PK::ECC self, SV * key_data, SV * curve)
PPCODE:
{
int rv, type;
unsigned char *data=NULL;
STRLEN data_len=0;
data = (unsigned char *)SvPVbyte(key_data, data_len);
if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
/* setup dp structure */
rv = _ecc_set_dp_from_SV(&self->key, curve); /* croaks on error */
if (rv != CRYPT_OK) croak("FATAL: ecc_set_dp failed: %s", error_to_string(rv));
/* import key */
type = (data_len == (STRLEN)ecc_get_size(&self->key)) ? PK_PRIVATE : PK_PUBLIC;
rv = ecc_set_key(data, (unsigned long)data_len, type, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_set_key failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
int
is_private(Crypt::PK::ECC self)
CODE:
if (self->key.type == -1) XSRETURN_UNDEF;
RETVAL = (self->key.type == PK_PRIVATE) ? 1 : 0;
OUTPUT:
RETVAL
int
size(Crypt::PK::ECC self)
CODE:
if (self->key.type == -1) XSRETURN_UNDEF;
RETVAL = ecc_get_size(&self->key);
OUTPUT:
RETVAL
SV*
key2hash(Crypt::PK::ECC self)
PREINIT:
HV *rv_hash;
long siz, esize;
char buf[20001];
SV **not_used;
CODE:
if (self->key.type == -1) XSRETURN_UNDEF;
esize = ecc_get_size(&self->key);
rv_hash = newHV();
/* k */
siz = (self->key.k) ? mp_unsigned_bin_size(self->key.k) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'k' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.k, buf, 20000, esize*2);
not_used = hv_store(rv_hash, "k", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "k", 1, newSVpv("", 0), 0);
}
/* pub_x */
siz = (self->key.pubkey.x) ? mp_unsigned_bin_size(self->key.pubkey.x) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'pub_x' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.pubkey.x, buf, 20000, esize*2);
not_used = hv_store(rv_hash, "pub_x", 5, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "pub_x", 5, newSVpv("", 0), 0);
}
/* pub_y */
siz = (self->key.pubkey.y) ? mp_unsigned_bin_size(self->key.pubkey.y) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'pub_y' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.pubkey.y, buf, 20000, esize*2);
not_used = hv_store(rv_hash, "pub_y", 5, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "pub_y", 5, newSVpv("", 0), 0);
}
/* curve_... */
{
not_used = hv_store(rv_hash, "curve_cofactor", 14, newSViv(self->key.dp.cofactor), 0);
mp_tohex_with_leading_zero(self->key.dp.prime, buf, 20000, 0);
not_used = hv_store(rv_hash, "curve_prime", 11, newSVpv(buf, strlen(buf)), 0);
mp_tohex_with_leading_zero(self->key.dp.A, buf, 20000, 0);
not_used = hv_store(rv_hash, "curve_A", 7, newSVpv(buf, strlen(buf)), 0);
mp_tohex_with_leading_zero(self->key.dp.B, buf, 20000, 0);
not_used = hv_store(rv_hash, "curve_B", 7, newSVpv(buf, strlen(buf)), 0);
mp_tohex_with_leading_zero(self->key.dp.order, buf, 20000, 0);
not_used = hv_store(rv_hash, "curve_order", 11, newSVpv(buf, strlen(buf)), 0);
mp_tohex_with_leading_zero(self->key.dp.base.x, buf, 20000, 0);
not_used = hv_store(rv_hash, "curve_Gx", 8, newSVpv(buf, strlen(buf)), 0);
mp_tohex_with_leading_zero(self->key.dp.base.y, buf, 20000, 0);
not_used = hv_store(rv_hash, "curve_Gy", 8, newSVpv(buf, strlen(buf)), 0);
not_used = hv_store(rv_hash, "curve_bytes", 11, newSViv(mp_unsigned_bin_size(self->key.dp.prime)), 0);
not_used = hv_store(rv_hash, "curve_bits", 10, newSViv(mp_count_bits(self->key.dp.prime)), 0);
if (self->key.dp.oidlen > 0) {
unsigned long i;
HV *h;
SV **pref, *cname;
char *cname_ptr, *oid_ptr;
STRLEN cname_len;
/* OID -> "curve_oid" */
SV *oid = newSVpv("", 0);
for(i = 0; i < self->key.dp.oidlen - 1; i++) sv_catpvf(oid, "%lu.", self->key.dp.oid[i]);
sv_catpvf(oid, "%lu", self->key.dp.oid[i]);
oid_ptr = SvPVX(oid);
not_used = hv_store(rv_hash, "curve_oid", 9, oid, 0);
/* curve name -> "curve_name" */
if ((h = get_hv("Crypt::PK::ECC::curve2ltc", 0)) != NULL) {
pref = hv_fetch(h, oid_ptr, (U32)strlen(oid_ptr), 0);
if (pref) {
cname_ptr = SvPV(*pref, cname_len);
cname = newSVpv(cname_ptr, cname_len);
cname_ptr = SvPVX(cname);
for (i=0; i<cname_len && cname_ptr[i]>0; i++) cname_ptr[i] = toLOWER(cname_ptr[i]);
not_used = hv_store(rv_hash, "curve_name", 10, cname, 0);
}
}
}
}
/* size */
not_used = hv_store(rv_hash, "size", 4, newSViv(esize), 0);
/* type */
not_used = hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0);
LTC_UNUSED_PARAM(not_used);
RETVAL = newRV_noinc((SV*)rv_hash);
OUTPUT:
RETVAL
SV *
export_key_der(Crypt::PK::ECC self, char * type)
CODE:
{
int rv;
unsigned char out[4096];
unsigned long int out_len = 4096;
if (self->key.type == -1) croak("FATAL: export_key_der no key");
if (strnEQ(type, "private_short", 16)) {
rv = ecc_export_openssl(out, &out_len, PK_PRIVATE|PK_CURVEOID, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PRIVATE|PK_CURVEOID) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "private_compressed", 16)) {
rv = ecc_export_openssl(out, &out_len, PK_PRIVATE|PK_CURVEOID|PK_COMPRESSED, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PRIVATE|PK_CURVEOID|PK_COMPRESSED) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "private", 7)) {
rv = ecc_export_openssl(out, &out_len, PK_PRIVATE, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PRIVATE) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "public_compressed", 15)) {
rv = ecc_export_openssl(out, &out_len, PK_PUBLIC|PK_CURVEOID|PK_COMPRESSED, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PUBLIC|PK_CURVEOID|PK_COMPRESSED) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "public_short", 15)) {
rv = ecc_export_openssl(out, &out_len, PK_PUBLIC|PK_CURVEOID, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PUBLIC|PK_CURVEOID) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "public", 6)) {
rv = ecc_export_openssl(out, &out_len, PK_PUBLIC, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PUBLIC) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else {
croak("FATAL: export_key_der invalid type '%s'", type);
}
}
OUTPUT:
RETVAL
SV *
export_key_raw(Crypt::PK::ECC self, char * type)
CODE:
{
int rv;
unsigned char out[4096];
unsigned long int out_len = sizeof(out);
if (self->key.type == -1) croak("FATAL: export_key_der no key");
if (strnEQ(type, "private", 7)) {
rv = ecc_get_key(out, &out_len, PK_PRIVATE, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_get_key(private) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "public_compressed", 17)) {
rv = ecc_get_key(out, &out_len, PK_PUBLIC|PK_COMPRESSED, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_get_key(public_compressed) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "public", 6)) {
rv = ecc_get_key(out, &out_len, PK_PUBLIC, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_get_key(public) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else {
croak("FATAL: export_key_raw invalid type '%s'", type);
}
}
OUTPUT:
RETVAL
SV *
encrypt(Crypt::PK::ECC self, SV * data, const char * hash_name = "SHA1")
CODE:
{
int rv, hash_id;
unsigned char *data_ptr=NULL;
STRLEN data_len=0;
unsigned char buffer[1024];
unsigned long buffer_len = 1024;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
hash_id = _find_hash(hash_name);
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = ecc_encrypt_key(data_ptr, (unsigned long)data_len, buffer, &buffer_len,
&self->pstate, self->pindex,
hash_id, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_encrypt_key failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
OUTPUT:
RETVAL
SV *
decrypt(Crypt::PK::ECC self, SV * data)
CODE:
{
int rv;
unsigned char *data_ptr=NULL;
STRLEN data_len=0;
unsigned char buffer[1024];
unsigned long buffer_len = 1024;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
rv = ecc_decrypt_key(data_ptr, (unsigned long)data_len, buffer, &buffer_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: ecc_decrypt_key_ex failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
OUTPUT:
RETVAL
SV *
sign_hash(Crypt::PK::ECC self, SV * data, const char * hash_name = "SHA1")
ALIAS:
sign_hash_rfc7518 = 3
sign_message = 1
sign_message_rfc7518 = 2
CODE:
{
int rv, id;
unsigned char buffer[1024], tmp[MAXBLOCKSIZE], *data_ptr = NULL;
unsigned long tmp_len = MAXBLOCKSIZE, buffer_len = 1024;
STRLEN data_len = 0;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
if (ix == 1 || ix == 2) {
id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = hash_memory(id, data_ptr, (unsigned long)data_len, tmp, &tmp_len);
if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv));
data_ptr = tmp;
data_len = tmp_len;
}
if (ix == 2 || ix == 3) {
rv = ecc_sign_hash_rfc7518(data_ptr, (unsigned long)data_len, buffer, &buffer_len,
&self->pstate, self->pindex,
&self->key);
}
else {
rv = ecc_sign_hash(data_ptr, (unsigned long)data_len, buffer, &buffer_len,
&self->pstate, self->pindex,
&self->key);
}
if (rv != CRYPT_OK) croak("FATAL: ecc_sign_hash_ex failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
OUTPUT:
RETVAL
int
verify_hash(Crypt::PK::ECC self, SV * sig, SV * data, const char * hash_name = "SHA1")
ALIAS:
verify_hash_rfc7518 = 3
verify_message = 1
verify_message_rfc7518 = 2
CODE:
{
int rv, stat, id;
unsigned char tmp[MAXBLOCKSIZE], *data_ptr = NULL, *sig_ptr = NULL;
unsigned long tmp_len = MAXBLOCKSIZE;
STRLEN data_len = 0, sig_len = 0;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
sig_ptr = (unsigned char *)SvPVbyte(sig, sig_len);
if (ix == 1 || ix == 2) {
id = _find_hash(hash_name);
if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = hash_memory(id, data_ptr, (unsigned long)data_len, tmp, &tmp_len);
if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv));
data_ptr = tmp;
data_len = tmp_len;
}
RETVAL = 1;
stat = 0;
if (ix == 2 || ix == 3) {
rv = ecc_verify_hash_rfc7518(sig_ptr, (unsigned long)sig_len, data_ptr, (unsigned long)data_len, &stat, &self->key);
}
else {
rv = ecc_verify_hash(sig_ptr, (unsigned long)sig_len, data_ptr, (unsigned long)data_len, &stat, &self->key);
}
if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
}
OUTPUT:
RETVAL
SV *
shared_secret(Crypt::PK::ECC self, Crypt::PK::ECC pubkey)
CODE:
{
int rv;
unsigned char buffer[1024];
unsigned long buffer_len = 1024;
rv = ecc_shared_secret(&self->key, &pubkey->key, buffer, &buffer_len);
if (rv != CRYPT_OK) croak("FATAL: ecc_shared_secret failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::PK::ECC self)
CODE:
if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
Safefree(self);

View File

@ -1,499 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::PK::RSA
PROTOTYPES: DISABLE
Crypt::PK::RSA
_new(Class)
CODE:
{
int rv;
Newz(0, RETVAL, 1, struct rsa_struct);
if (!RETVAL) croak("FATAL: Newz failed");
RETVAL->key.type = -1;
RETVAL->pindex = find_prng("chacha20");
if (RETVAL->pindex == -1) {
Safefree(RETVAL);
croak("FATAL: find_prng('chacha20') failed");
}
rv = rng_make_prng(320, RETVAL->pindex, &RETVAL->pstate, NULL); /* 320bits = 40bytes */
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: rng_make_prng failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
generate_key(Crypt::PK::RSA self, int key_size=256, long key_e=65537)
PPCODE:
{
/* key_size is in octets */
int rv;
/* gen the key */
rv = rsa_make_key(&self->pstate, self->pindex, key_size, key_e, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_make_key failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import(Crypt::PK::RSA self, SV * key_data)
PPCODE:
{
int rv;
unsigned char *data=NULL;
STRLEN data_len=0;
data = (unsigned char *)SvPVbyte(key_data, data_len);
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
rv = rsa_import(data, (unsigned long)data_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_import failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import_pkcs8(Crypt::PK::RSA self, SV * key_data, SV * passwd)
PPCODE:
{
int rv;
unsigned char *data=NULL, *pwd=NULL;
STRLEN data_len=0, pwd_len=0;
data = (unsigned char *)SvPVbyte(key_data, data_len);
if (SvOK(passwd)) {
pwd = (unsigned char *)SvPVbyte(passwd, pwd_len);
}
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
rv = rsa_import_pkcs8(data, (unsigned long)data_len, pwd, (unsigned long)pwd_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_import_pkcs8 failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import_x509(Crypt::PK::RSA self, SV * key_data)
PPCODE:
{
int rv;
unsigned char *data=NULL;
STRLEN data_len=0;
data = (unsigned char *)SvPVbyte(key_data, data_len);
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
rv = rsa_import_x509(data, (unsigned long)data_len, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_import_x509 failed: %s", error_to_string(rv));
XPUSHs(ST(0)); /* return self */
}
void
_import_hex(Crypt::PK::RSA self, char *N, char *e, char *d=NULL, char *p=NULL, char *q=NULL, char *dP=NULL, char *dQ=NULL, char *qP=NULL)
PPCODE:
{
int rv;
unsigned char Nbin[1024], ebin[128], dbin[1024], pbin[512], qbin[512], dPbin[512], dQbin[512], qPbin[512];
unsigned long Nlen=sizeof(Nbin), elen=sizeof(ebin), dlen=sizeof(dbin), plen=sizeof(pbin),
qlen=sizeof(qbin), dPlen=sizeof(dPbin), dQlen=sizeof(dQbin), qPlen=sizeof(qPbin);
rv = radix_to_bin(N, 16, Nbin, &Nlen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(N) failed: %s", error_to_string(rv));
rv = radix_to_bin(e, 16, ebin, &elen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(e) failed: %s", error_to_string(rv));
if (d && strlen(d) > 0) {
/* private */
rv = radix_to_bin(d, 16, dbin, &dlen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(d) failed: %s", error_to_string(rv));
rv = rsa_set_key(Nbin, Nlen, ebin, elen, dbin, dlen, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_set_key failed: %s", error_to_string(rv));
}
else {
/* public */
rv = rsa_set_key(Nbin, Nlen, ebin, elen, NULL, 0, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_set_key failed: %s", error_to_string(rv));
}
if (p && strlen(p) > 0 && q && strlen(q) > 0) {
/* private only */
rv = radix_to_bin(p, 16, pbin, &plen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
rv = radix_to_bin(q, 16, qbin, &qlen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(q) failed: %s", error_to_string(rv));
rv = rsa_set_factors(pbin, plen, qbin, qlen, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_set_factors failed: %s", error_to_string(rv));
}
if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) {
/* private only */
rv = radix_to_bin(dP, 16, dPbin, &dPlen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(dP) failed: %s", error_to_string(rv));
rv = radix_to_bin(dQ, 16, dQbin, &dQlen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(dQ) failed: %s", error_to_string(rv));
rv = radix_to_bin(qP, 16, qPbin, &qPlen);
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(qP) failed: %s", error_to_string(rv));
rv = rsa_set_crt_params(dPbin, dPlen, dQbin, dQlen, qPbin, qPlen, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_set_crt_params failed: %s", error_to_string(rv));
}
XPUSHs(ST(0)); /* return self */
}
int
is_private(Crypt::PK::RSA self)
CODE:
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF;
RETVAL = (self->key.type == PK_PRIVATE) ? 1 : 0;
OUTPUT:
RETVAL
int
size(Crypt::PK::RSA self)
CODE:
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF;
RETVAL = mp_unsigned_bin_size(self->key.N);
OUTPUT:
RETVAL
SV*
key2hash(Crypt::PK::RSA self)
PREINIT:
HV *rv_hash;
long siz, nsize;
char buf[20001];
SV **not_used;
CODE:
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF;
nsize = mp_unsigned_bin_size(self->key.N);
rv_hash = newHV();
/* e */
siz = (self->key.e) ? mp_unsigned_bin_size(self->key.e) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'e' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.e, buf, 20000, 0);
not_used = hv_store(rv_hash, "e", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "e", 1, newSVpv("", 0), 0);
}
/* d */
siz = (self->key.d) ? mp_unsigned_bin_size(self->key.d) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'd' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.d, buf, 20000, 0);
not_used = hv_store(rv_hash, "d", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "d", 1, newSVpv("", 0), 0);
}
/* N */
siz = (self->key.N) ? nsize : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'N' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.N, buf, 20000, 0);
not_used = hv_store(rv_hash, "N", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "N", 1, newSVpv("", 0), 0);
}
/* q */
siz = (self->key.q) ? mp_unsigned_bin_size(self->key.q) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'q' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.q, buf, 20000, 0);
not_used = hv_store(rv_hash, "q", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "q", 1, newSVpv("", 0), 0);
}
/* p */
siz = (self->key.p) ? mp_unsigned_bin_size(self->key.p) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'p' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.p, buf, 20000, 0);
not_used = hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "p", 1, newSVpv("", 0), 0);
}
/* qP */
siz = (self->key.qP) ? mp_unsigned_bin_size(self->key.qP) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'qP' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.qP, buf, 20000, 0);
not_used = hv_store(rv_hash, "qP", 2, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "qP", 2, newSVpv("", 0), 0);
}
/* dP */
siz = (self->key.dP) ? mp_unsigned_bin_size(self->key.dP) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'dP' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.dP, buf, 20000, 0);
not_used = hv_store(rv_hash, "dP", 2, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "dP", 2, newSVpv("", 0), 0);
}
/* dQ */
siz = (self->key.dQ) ? mp_unsigned_bin_size(self->key.dQ) : 0;
if (siz>10000) {
croak("FATAL: key2hash failed - 'dQ' too big number");
}
if (siz>0) {
mp_tohex_with_leading_zero(self->key.dQ, buf, 20000, 0);
not_used = hv_store(rv_hash, "dQ", 2, newSVpv(buf, strlen(buf)), 0);
}
else{
not_used = hv_store(rv_hash, "dQ", 2, newSVpv("", 0), 0);
}
/* size */
not_used = hv_store(rv_hash, "size", 4, newSViv(nsize), 0);
/* type */
not_used = hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0);
LTC_UNUSED_PARAM(not_used);
RETVAL = newRV_noinc((SV*)rv_hash);
OUTPUT:
RETVAL
SV*
export_key_der(Crypt::PK::RSA self, char * type)
CODE:
{
int rv;
unsigned char out[4096];
unsigned long out_len = 4096;
RETVAL = newSVpvn(NULL, 0); /* undef */
if (strnEQ(type, "private", 7)) {
rv = rsa_export(out, &out_len, PK_PRIVATE, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_export(PK_PRIVATE) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else if (strnEQ(type, "public", 6)) {
rv = rsa_export(out, &out_len, PK_PUBLIC|PK_STD, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_export(PK_PUBLIC|PK_STD) failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)out, out_len);
}
else {
croak("FATAL: export_key_der invalid type '%s'", type);
}
}
OUTPUT:
RETVAL
SV *
encrypt(Crypt::PK::RSA self, SV * data, const char * padding = "oaep", const char * oaep_hash = "SHA1", SV * oaep_lparam = NULL)
CODE:
{
int rv, hash_id;
unsigned char *lparam_ptr=NULL;
STRLEN lparam_len=0;
unsigned char *data_ptr=NULL;
STRLEN data_len=0;
unsigned char buffer[1024];
unsigned long buffer_len = 1024;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
RETVAL = newSVpvn(NULL, 0); /* undef */
if (strnEQ(padding, "oaep", 4)) {
hash_id = _find_hash(oaep_hash);
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", oaep_hash);
if (oaep_lparam) lparam_ptr = (unsigned char *)SvPVbyte(oaep_lparam, lparam_len);
rv = rsa_encrypt_key_ex(data_ptr, (unsigned long)data_len, buffer, &buffer_len, lparam_ptr, (unsigned long)lparam_len,
&self->pstate, self->pindex,
hash_id, LTC_PKCS_1_OAEP, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_encrypt_key_ex failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
else if (strnEQ(padding, "v1.5", 4)) {
rv = rsa_encrypt_key_ex(data_ptr, (unsigned long)data_len, buffer, &buffer_len, NULL, 0,
&self->pstate, self->pindex,
0, LTC_PKCS_1_V1_5, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_encrypt_key_ex failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
else if (strnEQ(padding, "none", 4)) {
/* raw RSA */
rv = ltc_mp.rsa_me(data_ptr, (unsigned long)data_len, buffer, &buffer_len, PK_PUBLIC, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
else {
croak("FATAL: rsa_encrypt invalid padding '%s'", padding);
}
}
OUTPUT:
RETVAL
SV *
decrypt(Crypt::PK::RSA self, SV * data, const char * padding = "oaep", const char * oaep_hash = "SHA1", SV * oaep_lparam = NULL)
CODE:
{
int rv, hash_id, stat;
unsigned char *lparam_ptr=NULL;
STRLEN lparam_len=0;
unsigned char *data_ptr=NULL;
STRLEN data_len=0;
unsigned char buffer[1024];
unsigned long buffer_len = 1024;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
RETVAL = newSVpvn(NULL, 0); /* undef */
if (strnEQ(padding, "oaep", 4)) {
hash_id = _find_hash(oaep_hash);
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", oaep_hash);
if (oaep_lparam) lparam_ptr = (unsigned char *)SvPVbyte(oaep_lparam, lparam_len);
rv = rsa_decrypt_key_ex(data_ptr, (unsigned long)data_len, buffer, &buffer_len, lparam_ptr, (unsigned long)lparam_len,
hash_id, LTC_PKCS_1_OAEP, &stat, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_decrypt_key_ex failed: %s", error_to_string(rv));
if (stat != 1) croak("FATAL: rsa_decrypt - not valid OAEP packet");
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
else if (strnEQ(padding, "v1.5", 4)) {
rv = rsa_decrypt_key_ex(data_ptr, (unsigned long)data_len, buffer, &buffer_len, NULL, 0,
0, LTC_PKCS_1_V1_5, &stat, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_decrypt_key_ex failed: %s", error_to_string(rv));
if (stat != 1) croak("FATAL: rsa_decrypt - invalid");
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
else if (strnEQ(padding, "none", 4)) {
/* raw RSA */
rv = ltc_mp.rsa_me(data_ptr, (unsigned long)data_len, buffer, &buffer_len, PK_PRIVATE, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
else {
croak("FATAL: rsa_encrypt invalid padding '%s'", padding);
}
}
OUTPUT:
RETVAL
SV *
sign_hash(Crypt::PK::RSA self, SV * data, const char * hash_name = "SHA1", const char * padding = "pss", unsigned long saltlen=12)
ALIAS:
sign_message = 1
CODE:
{
int rv, hash_id;
unsigned char buffer[1024], tmp[MAXBLOCKSIZE], *data_ptr = NULL;
unsigned long tmp_len = MAXBLOCKSIZE, buffer_len = 1024;
STRLEN data_len = 0;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
if (ix == 1) {
hash_id = _find_hash(hash_name);
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = hash_memory(hash_id, data_ptr, (unsigned long)data_len, tmp, &tmp_len);
if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv));
data_ptr = tmp;
data_len = tmp_len;
}
if (strnEQ(padding, "pss", 3)) {
hash_id = _find_hash(hash_name);
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = rsa_sign_hash_ex(data_ptr, (unsigned long)data_len, buffer, &buffer_len, LTC_PKCS_1_PSS,
&self->pstate, self->pindex,
hash_id, saltlen, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_sign_hash_ex failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
else if (strnEQ(padding, "v1.5", 4)) {
hash_id = _find_hash(hash_name);
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = rsa_sign_hash_ex(data_ptr, (unsigned long)data_len, buffer, &buffer_len, LTC_PKCS_1_V1_5,
&self->pstate, self->pindex,
hash_id, 0, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_sign_hash_ex failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
else if (strnEQ(padding, "none", 4)) {
/* raw RSA */
rv = ltc_mp.rsa_me(data_ptr, (unsigned long)data_len, buffer, &buffer_len, PK_PRIVATE, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv));
RETVAL = newSVpvn((char*)buffer, buffer_len);
}
else {
croak("FATAL: rsa_sign invalid padding '%s'", padding);
}
}
OUTPUT:
RETVAL
int
verify_hash(Crypt::PK::RSA self, SV * sig, SV * data, const char * hash_name = "SHA1", const char * padding = "pss", unsigned long saltlen = 12)
ALIAS:
verify_message = 1
CODE:
{
int rv, hash_id, stat;
unsigned char tmp[MAXBLOCKSIZE], buffer[1024], *data_ptr = NULL, *sig_ptr = NULL;
unsigned long i, tmp_len = MAXBLOCKSIZE, buffer_len = 1024;
STRLEN data_len = 0, sig_len = 0;
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
sig_ptr = (unsigned char *)SvPVbyte(sig, sig_len);
if (ix == 1) {
hash_id = _find_hash(hash_name);
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = hash_memory(hash_id, data_ptr, (unsigned long)data_len, tmp, &tmp_len);
if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv));
data_ptr = tmp;
data_len = tmp_len;
}
RETVAL = 1;
stat = 0;
if (strnEQ(padding, "pss", 3)) {
hash_id = _find_hash(hash_name);
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = rsa_verify_hash_ex(sig_ptr, (unsigned long)sig_len, data_ptr, (unsigned long)data_len, LTC_PKCS_1_PSS,
hash_id, saltlen, &stat, &self->key);
if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
}
else if (strnEQ(padding, "v1.5", 4)) {
hash_id = _find_hash(hash_name);
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
rv = rsa_verify_hash_ex(sig_ptr, (unsigned long)sig_len, data_ptr, (unsigned long)data_len, LTC_PKCS_1_V1_5,
hash_id, 0, &stat, &self->key);
if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
}
else if (strnEQ(padding, "none", 4)) {
/* raw RSA */
Zero(buffer, buffer_len, unsigned char);
rv = ltc_mp.rsa_me(sig_ptr, (unsigned long)sig_len, buffer, &buffer_len, PK_PUBLIC, &self->key);
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv));
if (data_len <= buffer_len && buffer_len > 0 && data_len > 0) {
for (i = 0; i < buffer_len - data_len; i++) if (buffer[i] != 0) RETVAL = 0;
if (memNE(data_ptr, buffer + buffer_len - data_len, data_len)) RETVAL = 0;
}
else {
RETVAL = 0;
}
}
else {
croak("FATAL: rsa_verify invalid padding '%s'", padding);
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::PK::RSA self)
CODE:
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
Safefree(self);

View File

@ -1,227 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::PRNG
PROTOTYPES: DISABLE
Crypt::PRNG
new(char * class, ...)
CODE:
{
IV curpid = (IV)PerlProc_getpid();
int rv, id, idx;
unsigned char *ent=NULL;
STRLEN ent_len=0;
unsigned char entropy_buf[40];
char *prng_name = (char *)"ChaCha20";
SV *entropy = &PL_sv_undef;
/* we need to handle:
Crypt::PRNG->new('RC4');
Crypt::Cipher::RC4->new();
*/
idx = strcmp("Crypt::PRNG", class) == 0 ? 1 : 0;
if (idx + 1 <= items) prng_name = SvPVX(ST(idx));
if (idx + 2 <= items) entropy = ST(idx + 1);
Newz(0, RETVAL, 1, struct prng_struct);
if (!RETVAL) croak("FATAL: Newz failed");
id = _find_prng(prng_name);
if (id == -1) {
Safefree(RETVAL);
croak("FATAL: find_prng failed for '%s'", prng_name);
}
RETVAL->last_pid = curpid;
RETVAL->desc = &prng_descriptor[id];
rv = RETVAL->desc->start(&RETVAL->state);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: PRNG_start failed: %s", error_to_string(rv));
}
if (SvOK(entropy)) {
ent = (unsigned char *) SvPVbyte(entropy, ent_len);
rv = RETVAL->desc->add_entropy(ent, (unsigned long)ent_len, &RETVAL->state);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: PRNG_add_entropy failed: %s", error_to_string(rv));
}
}
else {
if (rng_get_bytes(entropy_buf, 40, NULL) != 40) {
Safefree(RETVAL);
croak("FATAL: rng_get_bytes failed: %s", error_to_string(rv));
}
rv = RETVAL->desc->add_entropy(entropy_buf, 40, &RETVAL->state);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: PRNG_add_entropy failed: %s", error_to_string(rv));
}
}
rv = RETVAL->desc->ready(&RETVAL->state);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: PRNG_ready failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::PRNG self)
CODE:
Safefree(self);
void
add_entropy(Crypt::PRNG self, SV * entropy=&PL_sv_undef)
CODE:
{
STRLEN in_len=0;
unsigned char *in_buffer=NULL;
unsigned char entropy_buf[40];
int rv;
if (SvOK(entropy)) {
in_buffer = (unsigned char *) SvPVbyte(entropy, in_len);
rv = self->desc->add_entropy(in_buffer, (unsigned long)in_len, &self->state);
if (rv != CRYPT_OK) croak("FATAL: PRNG_add_entropy failed: %s", error_to_string(rv));
}
else {
if (rng_get_bytes(entropy_buf, 40, NULL) != 40) croak("FATAL: rng_get_bytes failed");
rv = self->desc->add_entropy(entropy_buf, 40, &self->state);
if (rv != CRYPT_OK) croak("FATAL: PRNG_add_entropy failed: %s", error_to_string(rv));
}
rv = self->desc->ready(&self->state);
if (rv != CRYPT_OK) croak("FATAL: PRNG_ready failed: %s", error_to_string(rv));
}
SV *
bytes(Crypt::PRNG self, unsigned long output_len)
ALIAS:
bytes_hex = 1
bytes_b64 = 2
bytes_b64u = 3
CODE:
{
IV curpid = (IV)PerlProc_getpid();
int rv_len, rv;
unsigned long len;
unsigned char *rdata, *tmp;
unsigned char entropy_buf[40];
if (output_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
if (self->last_pid != curpid) {
if (rng_get_bytes(entropy_buf, 40, NULL) != 40) croak("FATAL: rng_get_bytes failed");
self->desc->add_entropy(entropy_buf, 40, &self->state);
self->desc->ready(&self->state);
self->last_pid = curpid;
}
if (ix == 1) {
/* HEX */
Newz(0, tmp, output_len, unsigned char);
if (tmp == NULL) croak("FATAL: Newz failed");
rv_len = (self->desc->read)(tmp, (unsigned long)output_len, &self->state);
if ((UV)rv_len != output_len) croak("FATAL: PRNG_read failed");
RETVAL = NEWSV(0, output_len * 2); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, output_len * 2);
rdata = (unsigned char *)SvPVX(RETVAL);
len = output_len * 2;
rv = _base16_encode(tmp, output_len, rdata, &len);
Safefree(tmp);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: base16_encode failed");
}
}
else if (ix == 2 || ix == 3) {
/* BASE64 or BASE64URL */
Newz(0, tmp, output_len, unsigned char);
if (tmp == NULL) croak("FATAL: Newz failed");
rv_len = (self->desc->read)(tmp, (unsigned long)output_len, &self->state);
if ((UV)rv_len != output_len) croak("FATAL: PRNG_read failed");
RETVAL = NEWSV(0, output_len * 2); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, output_len * 2);
rdata = (unsigned char *)SvPVX(RETVAL);
len = output_len * 2;
rv = ix == 3 ? base64url_encode(tmp, output_len, rdata, &len) :
base64_encode(tmp, output_len, rdata, &len);
SvCUR_set(RETVAL, len);
Safefree(tmp);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak(ix == 3 ? "FATAL: base64url_encode failed" : "FATAL: base64_encode failed");
}
}
else {
/* RAW BYTES */
RETVAL = NEWSV(0, output_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, output_len);
rdata = (unsigned char *)SvPVX(RETVAL);
rv_len = (self->desc->read)(rdata, (unsigned long)output_len, &self->state);
if ((UV)rv_len != output_len) {
SvREFCNT_dec(RETVAL);
croak("FATAL: PRNG_read failed");
}
}
}
}
OUTPUT:
RETVAL
UV
int32(Crypt::PRNG self)
CODE:
{
IV curpid = (IV)PerlProc_getpid();
int i;
unsigned char rdata[4];
unsigned char entropy_buf[40];
if (self->last_pid != curpid) {
if (rng_get_bytes(entropy_buf, 40, NULL) != 40) croak("FATAL: rng_get_bytes failed");
self->desc->add_entropy(entropy_buf, 40, &self->state);
self->desc->ready(&self->state);
self->last_pid = curpid;
}
i = (self->desc->read)(rdata, 4, &self->state);
if (i != 4) croak("FATAL: PRNG_read failed");
RETVAL = ((UV)(rdata[0])<<24) + ((UV)(rdata[1])<<16) + ((UV)(rdata[2])<<8) + ((UV)(rdata[3]));
}
OUTPUT:
RETVAL
NV
double(Crypt::PRNG self, SV * limit_sv = NULL)
CODE:
{
IV curpid = (IV)PerlProc_getpid();
int i;
unsigned long a, b; /* 32bit is enough */
unsigned char rdata[7]; /* for double we need 53 bits */
unsigned char entropy_buf[40];
if (self->last_pid != curpid) {
if (rng_get_bytes(entropy_buf, 40, NULL) != 40) croak("FATAL: rng_get_bytes failed");
self->desc->add_entropy(entropy_buf, 40, &self->state);
self->desc->ready(&self->state);
self->last_pid = curpid;
}
i = (self->desc->read)(rdata, 7, &self->state);
if (i != 7) croak("FATAL: PRNG_read failed");
a = (((unsigned long)(rdata[0])<<16) + ((unsigned long)(rdata[1])<<8) + ((unsigned long)(rdata[2]))) & 0x1FFFFF; /* 21 bits */
b = ((unsigned long)(rdata[3])<<24) + ((unsigned long)(rdata[4])<<16) + ((unsigned long)(rdata[5])<<8) + ((unsigned long)(rdata[6])); /* 32 bits */
RETVAL = ( (NV)a * 4294967296.0 + (NV)b ) / 9007199254740992.0; /* (a * 2^32 + b) / 2^53 */
if (limit_sv && SvOK(limit_sv)) {
NV limit = SvNV(limit_sv);
if (limit > 0 || limit < 0) RETVAL = RETVAL * limit;
}
}
OUTPUT:
RETVAL

View File

@ -1,114 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Stream::ChaCha
PROTOTYPES: DISABLE
Crypt::Stream::ChaCha
new(Class, SV * key, SV * nonce, UV counter = 0, int rounds = 20)
CODE:
{
int rv;
STRLEN iv_len=0, k_len=0;
unsigned char *iv=NULL, *k=NULL;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
iv = (unsigned char *) SvPVbyte(nonce, iv_len);
Newz(0, RETVAL, 1, chacha_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = chacha_setup(RETVAL, k, (unsigned long)k_len, rounds);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: chacha_setup failed: %s", error_to_string(rv));
}
if (iv_len == 12) {
rv = chacha_ivctr32(RETVAL, iv, (unsigned long)iv_len, (ulong32)counter);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: chacha_ivctr32 failed: %s", error_to_string(rv));
}
}
else if (iv_len == 8) {
rv = chacha_ivctr64(RETVAL, iv, (unsigned long)iv_len, (ulong64)counter);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: chacha_ivctr64 failed: %s", error_to_string(rv));
}
}
else {
Safefree(RETVAL);
croak("FATAL: chacha IV length must be 8 or 12 bytes");
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Stream::ChaCha self)
CODE:
chacha_done(self);
Safefree(self);
Crypt::Stream::ChaCha
clone(Crypt::Stream::ChaCha self)
CODE:
Newz(0, RETVAL, 1, chacha_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, chacha_state);
OUTPUT:
RETVAL
SV *
keystream(Crypt::Stream::ChaCha self, STRLEN out_len)
CODE:
{
int rv;
unsigned char *out_data;
if (out_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, out_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = chacha_keystream(self, out_data, (unsigned long)out_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: chacha_keystream failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
crypt(Crypt::Stream::ChaCha self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = chacha_crypt(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: chacha_crypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL

View File

@ -1,93 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Stream::RC4
PROTOTYPES: DISABLE
Crypt::Stream::RC4
new(Class, SV * key)
CODE:
{
int rv;
STRLEN k_len=0;
unsigned char *k=NULL;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, rc4_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = rc4_stream_setup(RETVAL, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: rc4_stream_setup failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Stream::RC4 self)
CODE:
rc4_stream_done(self);
Safefree(self);
Crypt::Stream::RC4
clone(Crypt::Stream::RC4 self)
CODE:
Newz(0, RETVAL, 1, rc4_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, rc4_state);
OUTPUT:
RETVAL
SV *
keystream(Crypt::Stream::RC4 self, STRLEN out_len)
CODE:
{
int rv;
unsigned char *out_data;
if (out_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, out_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = rc4_stream_keystream(self, out_data, (unsigned long)out_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: rc4_stream_keystream failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
crypt(Crypt::Stream::RC4 self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = rc4_stream_crypt(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: rc4_stream_crypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL

View File

@ -1,104 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Stream::Rabbit
PROTOTYPES: DISABLE
Crypt::Stream::Rabbit
new(Class, SV * key, SV * nonce=&PL_sv_undef)
CODE:
{
int rv;
STRLEN iv_len=0, k_len=0;
unsigned char *iv=NULL, *k=NULL;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *)SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, rabbit_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = rabbit_setup(RETVAL, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: rabbit_setup failed: %s", error_to_string(rv));
}
if (SvOK(nonce)) {
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
iv = (unsigned char *)SvPVbyte(nonce, iv_len);
rv = rabbit_setiv(RETVAL, iv, (unsigned long)iv_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: rabbit_setiv failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Stream::Rabbit self)
CODE:
rabbit_done(self);
Safefree(self);
Crypt::Stream::Rabbit
clone(Crypt::Stream::Rabbit self)
CODE:
Newz(0, RETVAL, 1, rabbit_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, rabbit_state);
OUTPUT:
RETVAL
SV *
keystream(Crypt::Stream::Rabbit self, STRLEN out_len)
CODE:
{
int rv;
unsigned char *out_data;
if (out_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, out_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = rabbit_keystream(self, out_data, (unsigned long)out_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: rabbit_keystream failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
crypt(Crypt::Stream::Rabbit self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = rabbit_crypt(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: rabbit_crypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL

View File

@ -1,101 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Stream::Salsa20
PROTOTYPES: DISABLE
Crypt::Stream::Salsa20
new(Class, SV * key, SV * nonce, UV counter = 0, int rounds = 20)
CODE:
{
int rv;
STRLEN iv_len=0, k_len=0;
unsigned char *iv=NULL, *k=NULL;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
k = (unsigned char *)SvPVbyte(key, k_len);
iv = (unsigned char *)SvPVbyte(nonce, iv_len);
Newz(0, RETVAL, 1, salsa20_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = salsa20_setup(RETVAL, k, (unsigned long)k_len, rounds);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: salsa20_setup failed: %s", error_to_string(rv));
}
rv = salsa20_ivctr64(RETVAL, iv, (unsigned long)iv_len, (ulong64)counter);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: salsa20_ivctr64 failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Stream::Salsa20 self)
CODE:
salsa20_done(self);
Safefree(self);
Crypt::Stream::Salsa20
clone(Crypt::Stream::Salsa20 self)
CODE:
Newz(0, RETVAL, 1, salsa20_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, salsa20_state);
OUTPUT:
RETVAL
SV *
keystream(Crypt::Stream::Salsa20 self, STRLEN out_len)
CODE:
{
int rv;
unsigned char *out_data;
if (out_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, out_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = salsa20_keystream(self, out_data, (unsigned long)out_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: salsa20_keystream failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
crypt(Crypt::Stream::Salsa20 self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = salsa20_crypt(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: salsa20_crypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL

View File

@ -1,101 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Stream::Sober128
PROTOTYPES: DISABLE
Crypt::Stream::Sober128
new(Class, SV * key, SV * nonce)
CODE:
{
int rv;
STRLEN iv_len=0, k_len=0;
unsigned char *iv=NULL, *k=NULL;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
k = (unsigned char *) SvPVbyte(key, k_len);
iv = (unsigned char *) SvPVbyte(nonce, iv_len);
Newz(0, RETVAL, 1, sober128_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = sober128_stream_setup(RETVAL, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: sober128_stream_setup failed: %s", error_to_string(rv));
}
rv = sober128_stream_setiv(RETVAL, iv, (unsigned long)iv_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: sober128_stream_setiv failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Stream::Sober128 self)
CODE:
sober128_stream_done(self);
Safefree(self);
Crypt::Stream::Sober128
clone(Crypt::Stream::Sober128 self)
CODE:
Newz(0, RETVAL, 1, sober128_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, sober128_state);
OUTPUT:
RETVAL
SV *
keystream(Crypt::Stream::Sober128 self, STRLEN out_len)
CODE:
{
int rv;
unsigned char *out_data;
if (out_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, out_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = sober128_stream_keystream(self, out_data, (unsigned long)out_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: sober128_stream_keystream failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
crypt(Crypt::Stream::Sober128 self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = sober128_stream_crypt(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: sober128_stream_crypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL

View File

@ -1,107 +0,0 @@
MODULE = CryptX PACKAGE = Crypt::Stream::Sosemanuk
PROTOTYPES: DISABLE
Crypt::Stream::Sosemanuk
new(Class, SV * key, SV * nonce=&PL_sv_undef)
CODE:
{
int rv;
STRLEN iv_len=0, k_len=0;
unsigned char *iv=NULL, *k=NULL;
if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
k = (unsigned char *)SvPVbyte(key, k_len);
Newz(0, RETVAL, 1, sosemanuk_state);
if (!RETVAL) croak("FATAL: Newz failed");
rv = sosemanuk_setup(RETVAL, k, (unsigned long)k_len);
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: sosemanuk_setup failed: %s", error_to_string(rv));
}
if (SvOK(nonce)) {
if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
iv = (unsigned char *)SvPVbyte(nonce, iv_len);
rv = sosemanuk_setiv(RETVAL, iv, (unsigned long)iv_len);
}
else {
rv = sosemanuk_setiv(RETVAL, NULL, 0);
}
if (rv != CRYPT_OK) {
Safefree(RETVAL);
croak("FATAL: sosemanuk_setiv failed: %s", error_to_string(rv));
}
}
OUTPUT:
RETVAL
void
DESTROY(Crypt::Stream::Sosemanuk self)
CODE:
sosemanuk_done(self);
Safefree(self);
Crypt::Stream::Sosemanuk
clone(Crypt::Stream::Sosemanuk self)
CODE:
Newz(0, RETVAL, 1, sosemanuk_state);
if (!RETVAL) croak("FATAL: Newz failed");
Copy(self, RETVAL, 1, sosemanuk_state);
OUTPUT:
RETVAL
SV *
keystream(Crypt::Stream::Sosemanuk self, STRLEN out_len)
CODE:
{
int rv;
unsigned char *out_data;
if (out_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, out_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, out_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = sosemanuk_keystream(self, out_data, (unsigned long)out_len);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: sosemanuk_keystream failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL
SV *
crypt(Crypt::Stream::Sosemanuk self, SV * data)
CODE:
{
int rv;
STRLEN in_data_len;
unsigned char *in_data, *out_data;
in_data = (unsigned char *)SvPVbyte(data, in_data_len);
if (in_data_len == 0) {
RETVAL = newSVpvn("", 0);
}
else {
RETVAL = NEWSV(0, in_data_len); /* avoid zero! */
SvPOK_only(RETVAL);
SvCUR_set(RETVAL, in_data_len);
out_data = (unsigned char *)SvPVX(RETVAL);
rv = sosemanuk_crypt(self, in_data, (unsigned long)in_data_len, out_data);
if (rv != CRYPT_OK) {
SvREFCNT_dec(RETVAL);
croak("FATAL: sosemanuk_crypt failed: %s", error_to_string(rv));
}
}
}
OUTPUT:
RETVAL

View File

@ -1,17 +0,0 @@
package Crypt::AuthEnc;
use strict;
use warnings;
our $VERSION = '0.058_002';
### not used
1;
=pod
=head1 NAME
Crypt::AuthEnc - [internal only]
=cut

View File

@ -1,136 +0,0 @@
package Crypt::AuthEnc::CCM;
use strict;
use warnings;
our $VERSION = '0.058_002';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
our %EXPORT_TAGS = ( all => [qw( ccm_encrypt_authenticate ccm_decrypt_verify )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::AuthEnc::CCM - Authenticated encryption in CCM mode
=head1 SYNOPSIS
### OO interface
use Crypt::AuthEnc::CCM;
# encrypt and authenticate
my $ae = Crypt::AuthEnc::CCM->new("AES", $key, $iv, $adata, $tag_len, $pt_len);
my $ct = $ae->encrypt_add('data1');
$ct .= $ae->encrypt_add('data2');
$ct .= $ae->encrypt_add('data3');
my $tag = $ae->encrypt_done();
# decrypt and verify
my $ae = Crypt::AuthEnc::CCM->new("AES", $key, $iv, $adata, $tag_len, $pt_len);
my $pt = $ae->decrypt_add('ciphertext1');
$pt .= $ae->decrypt_add('ciphertext2');
$pt .= $ae->decrypt_add('ciphertext3');
my $tag = $ae->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag;
#or
my $result = $ae->decrypt_done($expected_tag); # 0 or 1
### functional interface
use Crypt::AuthEnc::CCM qw(ccm_encrypt_authenticate ccm_decrypt_verify);
($ciphertext, $tag) = ccm_encrypt_authenticate('AES', $key, $nonce, $adata, $tag_len, $plaintext);
$plaintext = ccm_decrypt_verify('AES', $key, $nonce, $adata, $ciphertext, $tag);
=head1 DESCRIPTION
CCM is a encrypt+authenticate mode that is centered around using AES (or any 16-byte cipher) as a primitive.
Unlike EAX and OCB mode, it is only meant for packet mode where the length of the input is known in advance.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::AuthEnc::CCM qw(ccm_encrypt_authenticate ccm_decrypt_verify);
=head1 FUNCTIONS
=head2 ccm_encrypt_authenticate
my ($ciphertext, $tag) = ccm_encrypt_authenticate($cipher, $key, $nonce, $adata, $tag_len, $plaintext);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... key of proper length (e.g. 128/192/256bits for AES)
# $nonce ... unique nonce/salt (no need to keep it secret)
# $adata ... additional authenticated data
# $tag_len . required length of output tag
CCM parameters should follow L<http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38c.pdf>
# tag length: 4, 6, 8, 10, 12, 14, 16 (reasonable minimum is 8)
# nonce length: 7, 8, 9, 10, 11, 12, 13 (if you are not sure, use 11)
# BEWARE nonce length determines max. enc/dec data size: max_data_size = 2^(8*(15-nonce_len))
=head2 ccm_decrypt_verify
my $plaintext = ccm_decrypt_verify($cipher, $key, $nonce, $adata, $ciphertext, $tag);
# on error returns undef
=head1 METHODS
=head2 new
my $ae = Crypt::AuthEnc::CCM->new($cipher, $key, $nonce, $adata, $tag_len, $pt_len);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... key of proper length (e.g. 128/192/256bits for AES)
# $nonce ... unique nonce/salt (no need to keep it secret)
# $adata ... additional authenticated data
# $tag_len . required length of output tag
# $pt_len .. expected length of plaintext/ciphertext to encrypt/decrypt
=head2 encrypt_add
$ciphertext = $ae->encrypt_add($data); # can be called multiple times
=head2 encrypt_done
my $tag = $ae->encrypt_done; # returns $tag value
=head2 decrypt_add
$plaintext = $ae->decrypt_add($ciphertext); # can be called multiple times
=head2 decrypt_done
my $tag = $ae->decrypt_done; # returns $tag value
#or
my $result = $ae->decrypt_done($tag); # returns 1 (success) or 0 (failure)
=head2 clone
my $ae_new = $ae->clone;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::AuthEnc::EAX|Crypt::AuthEnc::EAX>, L<Crypt::AuthEnc::GCM|Crypt::AuthEnc::GCM>, L<Crypt::AuthEnc::OCB|Crypt::AuthEnc::OCB>
=item * L<https://en.wikipedia.org/wiki/CCM_mode|https://en.wikipedia.org/wiki/CCM_mode>
=back
=cut

View File

@ -1,147 +0,0 @@
package Crypt::AuthEnc::ChaCha20Poly1305;
use strict;
use warnings;
our $VERSION = '0.058_002';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
our %EXPORT_TAGS = ( all => [qw( chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::AuthEnc::ChaCha20Poly1305 - Authenticated encryption in ChaCha20-Poly1305 mode
=head1 SYNOPSIS
### OO interface
use Crypt::AuthEnc::ChaCha20Poly1305;
# encrypt and authenticate
my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $ct = $ae->encrypt_add('data1');
$ct .= $ae->encrypt_add('data2');
$ct .= $ae->encrypt_add('data3');
my $tag = $ae->encrypt_done();
# decrypt and verify
my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $pt = $ae->decrypt_add('ciphertext1');
$pt .= $ae->decrypt_add('ciphertext2');
$pt .= $ae->decrypt_add('ciphertext3');
my $tag = $ae->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag;
#or
my $result = $ae->decrypt_done($expected_tag); # 0 or 1
### functional interface
use Crypt::AuthEnc::ChaCha20Poly1305 qw(chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify);
my ($ciphertext, $tag) = chacha20poly1305_encrypt_authenticate($key, $iv, $adata, $plaintext);
my $plaintext = chacha20poly1305_decrypt_verify($key, $iv, $adata, $ciphertext, $tag);
=head1 DESCRIPTION
Provides encryption and authentication based on ChaCha20 + Poly1305 as defined in RFC 7539 - L<https://tools.ietf.org/html/rfc7539>
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::AuthEnc::ChaCha20Poly1305 qw(chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify);
=head1 FUNCTIONS
=head2 chacha20poly1305_encrypt_authenticate
my ($ciphertext, $tag) = chacha20poly1305_encrypt_authenticate($key, $iv, $adata, $plaintext);
# $key ..... key of proper length (128 or 256 bits / 16 or 32 bytes)
# $iv ...... initialization vector (64 or 96 bits / 8 or 12 bytes)
# $adata ... additional authenticated data (optional)
=head2 chacha20poly1305_decrypt_verify
my $plaintext = chacha20poly1305_decrypt_verify($key, $iv, $adata, $ciphertext, $tag);
# on error returns undef
=head1 METHODS
=head2 new
my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key, $iv);
# $key ..... encryption key of proper length (128 or 256 bits / 16 or 32 bytes)
# $iv ...... initialization vector (64 or 96 bits / 8 or 12 bytes)
=head2 adata_add
Add B<additional authenticated data>.
Can be called before the first C<encrypt_add> or C<decrypt_add>;
$ae->adata_add($aad_data); # can be called multiple times
=head2 encrypt_add
$ciphertext = $ae->encrypt_add($data); # can be called multiple times
=head2 encrypt_done
$tag = $ae->encrypt_done(); # returns $tag value
=head2 decrypt_add
$plaintext = $ae->decrypt_add($ciphertext); # can be called multiple times
=head2 decrypt_done
my $tag = $ae->decrypt_done; # returns $tag value
#or
my $result = $ae->decrypt_done($tag); # returns 1 (success) or 0 (failure)
=head2 set_iv
my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key)->set_iv($iv);
# $iv ...... initialization vector (64 or 96 bits / 8 or 12 bytes)
=head2 set_iv_rfc7905
See L<https://tools.ietf.org/html/rfc7905>
my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key)->set_iv_rfc7905($iv, $seqnum);
# $iv ...... initialization vector (96 bits / 12 bytes)
# $seqnum .. 64bit integer (sequence number)
=head2 clone
my $ae_new = $ae->clone;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::AuthEnc::GCM|Crypt::AuthEnc::GCM>, L<Crypt::AuthEnc::CCM|Crypt::AuthEnc::CCM>, L<Crypt::AuthEnc::EAX|Crypt::AuthEnc::EAX>, L<Crypt::AuthEnc::OCB|Crypt::AuthEnc::OCB>
=item * L<https://tools.ietf.org/html/rfc7539>
=back
=cut

View File

@ -1,142 +0,0 @@
package Crypt::AuthEnc::EAX;
use strict;
use warnings;
our $VERSION = '0.058_002';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
our %EXPORT_TAGS = ( all => [qw( eax_encrypt_authenticate eax_decrypt_verify )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
# obsolete, only for backwards compatibility
sub header_add { goto &adata_add }
sub aad_add { goto &adata_add }
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::AuthEnc::EAX - Authenticated encryption in EAX mode
=head1 SYNOPSIS
### OO interface
use Crypt::AuthEnc::EAX;
# encrypt and authenticate
my $ae = Crypt::AuthEnc::EAX->new("AES", $key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $ct = $ae->encrypt_add('data1');
$ct .= $ae->encrypt_add('data2');
$ct .= $ae->encrypt_add('data3');
my $tag = $ae->encrypt_done();
# decrypt and verify
my $ae = Crypt::AuthEnc::EAX->new("AES", $key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $pt = $ae->decrypt_add('ciphertext1');
$pt .= $ae->decrypt_add('ciphertext2');
$pt .= $ae->decrypt_add('ciphertext3');
my $tag = $ae->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag;
#or
my $result = $ae->decrypt_done($expected_tag); # 0 or 1
### functional interface
use Crypt::AuthEnc::EAX qw(eax_encrypt_authenticate eax_decrypt_verify);
my ($ciphertext, $tag) = eax_encrypt_authenticate('AES', $key, $iv, $adata, $plaintext);
my $plaintext = eax_decrypt_verify('AES', $key, $iv, $adata, $ciphertext, $tag);
=head1 DESCRIPTION
EAX is a mode that requires a cipher, CTR and OMAC support and provides encryption and authentication.
It is initialized with a random IV that can be shared publicly, additional authenticated data which can
be fixed and public, and a random secret symmetric key.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::AuthEnc::EAX qw(eax_encrypt_authenticate eax_decrypt_verify);
=head1 FUNCTIONS
=head2 eax_encrypt_authenticate
my ($ciphertext, $tag) = eax_encrypt_authenticate($cipher, $key, $iv, $adata, $plaintext);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... AES key of proper length (128/192/256bits)
# $iv ...... unique initialization vector (no need to keep it secret)
# $adata ... additional authenticated data
=head2 eax_decrypt_verify
my $plaintext = eax_decrypt_verify($cipher, $key, $iv, $adata, $ciphertext, $tag);
# on error returns undef
=head1 METHODS
=head2 new
my $ae = Crypt::AuthEnc::EAX->new($cipher, $key, $iv);
#or
my $ae = Crypt::AuthEnc::EAX->new($cipher, $key, $iv, $adata);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... AES key of proper length (128/192/256bits)
# $iv ...... unique initialization vector (no need to keep it secret)
# $adata ... additional authenticated data (optional)
=head2 adata_add
$ae->adata_add($adata); # can be called multiple times
=head2 encrypt_add
$ciphertext = $ae->encrypt_add($data); # can be called multiple times
=head2 encrypt_done
$tag = $ae->encrypt_done(); # returns $tag value
=head2 decrypt_add
$plaintext = $ae->decrypt_add($ciphertext); # can be called multiple times
=head2 decrypt_done
my $tag = $ae->decrypt_done; # returns $tag value
#or
my $result = $ae->decrypt_done($tag); # returns 1 (success) or 0 (failure)
=head2 clone
my $ae_new = $ae->clone;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::AuthEnc::CCM|Crypt::AuthEnc::CCM>, L<Crypt::AuthEnc::GCM|Crypt::AuthEnc::GCM>, L<Crypt::AuthEnc::OCB|Crypt::AuthEnc::OCB>
=item * L<https://en.wikipedia.org/wiki/EAX_mode|https://en.wikipedia.org/wiki/EAX_mode>
=back
=cut

View File

@ -1,148 +0,0 @@
package Crypt::AuthEnc::GCM;
use strict;
use warnings;
our $VERSION = '0.058_002';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
our %EXPORT_TAGS = ( all => [qw( gcm_encrypt_authenticate gcm_decrypt_verify )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::AuthEnc::GCM - Authenticated encryption in GCM mode
=head1 SYNOPSIS
### OO interface
use Crypt::AuthEnc::GCM;
# encrypt and authenticate
my $ae = Crypt::AuthEnc::GCM->new("AES", $key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $ct = $ae->encrypt_add('data1');
$ct .= $ae->encrypt_add('data2');
$ct .= $ae->encrypt_add('data3');
my $tag = $ae->encrypt_done();
# decrypt and verify
my $ae = Crypt::AuthEnc::GCM->new("AES", $key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $pt = $ae->decrypt_add('ciphertext1');
$pt .= $ae->decrypt_add('ciphertext2');
$pt .= $ae->decrypt_add('ciphertext3');
my $tag = $ae->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag;
#or
my $result = $ae->decrypt_done($expected_tag); # 0 or 1
### functional interface
use Crypt::AuthEnc::GCM qw(gcm_encrypt_authenticate gcm_decrypt_verify);
my ($ciphertext, $tag) = gcm_encrypt_authenticate('AES', $key, $iv, $adata, $plaintext);
my $plaintext = gcm_decrypt_verify('AES', $key, $iv, $adata, $ciphertext, $tag);
=head1 DESCRIPTION
Galois/Counter Mode (GCM) - provides encryption and authentication.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::AuthEnc::GCM qw(gcm_encrypt_authenticate gcm_decrypt_verify);
=head1 FUNCTIONS
=head2 gcm_encrypt_authenticate
my ($ciphertext, $tag) = gcm_encrypt_authenticate($cipher, $key, $iv, $adata, $plaintext);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... AES key of proper length (128/192/256bits)
# $iv ...... initialization vector
# $adata ... additional authenticated data
=head2 gcm_decrypt_verify
my $plaintext = gcm_decrypt_verify($cipher, $key, $iv, $adata, $ciphertext, $tag);
# on error returns undef
=head1 METHODS
=head2 new
my $ae = Crypt::AuthEnc::GCM->new($cipher, $key);
#or
my $ae = Crypt::AuthEnc::GCM->new($cipher, $key, $iv);
# $cipher .. 'AES' or name of any other cipher
# $key ..... encryption key of proper length
# $iv ...... initialization vector (optional, you can set it later via iv_add method)
=head2 iv_add
Set initialization vector (IV).
$ae->iv_add($iv_data); #can be called multiple times
=head2 adata_add
Add B<additional authenticated data>.
Can be called B<after> all C<iv_add> calls but before the first C<encrypt_add> or C<decrypt_add>.
$ae->adata_add($aad_data); # can be called multiple times
=head2 encrypt_add
$ciphertext = $ae->encrypt_add($data); # can be called multiple times
=head2 encrypt_done
$tag = $ae->encrypt_done(); # returns $tag value
=head2 decrypt_add
$plaintext = $ae->decrypt_add($ciphertext); # can be called multiple times
=head2 decrypt_done
my $tag = $ae->decrypt_done; # returns $tag value
#or
my $result = $ae->decrypt_done($tag); # returns 1 (success) or 0 (failure)
=head2 reset
$ae->reset;
=head2 clone
my $ae_new = $ae->clone;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::AuthEnc::CCM|Crypt::AuthEnc::CCM>, L<Crypt::AuthEnc::EAX|Crypt::AuthEnc::EAX>, L<Crypt::AuthEnc::OCB|Crypt::AuthEnc::OCB>
=item * L<https://en.wikipedia.org/wiki/Galois/Counter_Mode>
=back
=cut

View File

@ -1,155 +0,0 @@
package Crypt::AuthEnc::OCB;
use strict;
use warnings;
our $VERSION = '0.058_002';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
our %EXPORT_TAGS = ( all => [qw( ocb_encrypt_authenticate ocb_decrypt_verify )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
# obsolete, only for backwards compatibility
sub aad_add { goto &adata_add }
sub blocksize { return 16 }
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::AuthEnc::OCB - Authenticated encryption in OCBv3 mode
=head1 SYNOPSIS
### OO interface
use Crypt::AuthEnc::OCB;
# encrypt and authenticate
my $ae = Crypt::AuthEnc::OCB->new("AES", $key, $nonce, $tag_len);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $ct = $ae->encrypt_add('data1');
$ct .= $ae->encrypt_add('data2');
$ct .= $ae->encrypt_add('data3');
$ct .= $ae->encrypt_last('rest of data');
my $tag = $ae->encrypt_done();
# decrypt and verify
my $ae = Crypt::AuthEnc::OCB->new("AES", $key, $nonce, $tag_len);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $pt = $ae->decrypt_add('ciphertext1');
$pt .= $ae->decrypt_add('ciphertext2');
$pt .= $ae->decrypt_add('ciphertext3');
$pt .= $ae->decrypt_last('rest of data');
my $tag = $ae->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag;
#or
my $result = $ae->decrypt_done($expected_tag); # 0 or 1
### functional interface
use Crypt::AuthEnc::OCB qw(ocb_encrypt_authenticate ocb_decrypt_verify);
my ($ciphertext, $tag) = ocb_encrypt_authenticate('AES', $key, $nonce, $adata, $tag_len, $plaintext);
my $plaintext = ocb_decrypt_verify('AES', $key, $nonce, $adata, $ciphertext, $tag);
=head1 DESCRIPTION
This module implements OCB v3 according to L<https://tools.ietf.org/html/rfc7253>
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::AuthEnc::OCB qw(ocb_encrypt_authenticate ocb_decrypt_verify);
=head1 FUNCTIONS
=head2 ocb_encrypt_authenticate
my ($ciphertext, $tag) = ocb_encrypt_authenticate($cipher, $key, $nonce, $adata, $tag_len, $plaintext);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... AES key of proper length (128/192/256bits)
# $nonce ... unique nonce/salt (no need to keep it secret)
# $adata ... additional authenticated data
# $tag_len . required length of output tag
=head2 ocb_decrypt_verify
my $plaintext = ocb_decrypt_verify($cipher, $key, $nonce, $adata, $ciphertext, $tag);
# on error returns undef
=head1 METHODS
=head2 new
my $ae = Crypt::AuthEnc::OCB->new($cipher, $key, $nonce, $tag_len);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... AES key of proper length (128/192/256bits)
# $nonce ... unique nonce/salt (no need to keep it secret)
# $tag_len . required length of output tag
=head2 adata_add
$ae->adata_add($adata); #can be called multiple times
=head2 encrypt_add
$ciphertext = $ae->encrypt_add($data); # can be called multiple times
#BEWARE: size of $data has to be multiple of blocklen (16 for AES)
=head2 encrypt_last
$ciphertext = $ae->encrypt_last($data);
=head2 encrypt_done
$tag = $ae->encrypt_done(); # returns $tag value
=head2 decrypt_add
$plaintext = $ae->decrypt_add($ciphertext); # can be called multiple times
#BEWARE: size of $ciphertext has to be multiple of blocklen (16 for AES)
=head2 decrypt_last
$plaintext = $ae->decrypt_last($data);
=head2 decrypt_done
my $tag = $ae->decrypt_done; # returns $tag value
#or
my $result = $ae->decrypt_done($tag); # returns 1 (success) or 0 (failure)
=head2 clone
my $ae_new = $ae->clone;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::AuthEnc::CCM|Crypt::AuthEnc::CCM>, L<Crypt::AuthEnc::GCM|Crypt::AuthEnc::GCM>, L<Crypt::AuthEnc::EAX|Crypt::AuthEnc::EAX>
=item * L<https://en.wikipedia.org/wiki/OCB_mode>
=item * L<https://tools.ietf.org/html/rfc7253>
=back
=cut

View File

@ -1,69 +0,0 @@
package Crypt::Checksum;
use strict;
use warnings;
our $VERSION = '0.058_002';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
our %EXPORT_TAGS = ( all => [qw/ adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int
crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int /] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
# obsolete since v0.057, only for backwards compatibility
use Crypt::Checksum::CRC32;
use Crypt::Checksum::Adler32;
sub adler32_data { goto \&Crypt::Checksum::Adler32::adler32_data }
sub adler32_data_hex { goto \&Crypt::Checksum::Adler32::adler32_data_hex }
sub adler32_data_int { goto \&Crypt::Checksum::Adler32::adler32_data_int }
sub adler32_file { goto \&Crypt::Checksum::Adler32::adler32_file }
sub adler32_file_hex { goto \&Crypt::Checksum::Adler32::adler32_file_hex }
sub adler32_file_int { goto \&Crypt::Checksum::Adler32::adler32_file_int }
sub crc32_data { goto \&Crypt::Checksum::CRC32::crc32_data }
sub crc32_data_hex { goto \&Crypt::Checksum::CRC32::crc32_data_hex }
sub crc32_data_int { goto \&Crypt::Checksum::CRC32::crc32_data_int }
sub crc32_file { goto \&Crypt::Checksum::CRC32::crc32_file }
sub crc32_file_hex { goto \&Crypt::Checksum::CRC32::crc32_file_hex }
sub crc32_file_int { goto \&Crypt::Checksum::CRC32::crc32_file_int }
sub addfile {
my ($self, $file) = @_;
my $handle;
if (ref(\$file) eq 'SCALAR') { #filename
open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
binmode($handle);
}
else { #handle
$handle = $file
}
croak "FATAL: invalid handle" unless defined $handle;
my $n;
my $buf = "";
while (($n = read($handle, $buf, 32*1024))) {
$self->add($buf)
}
croak "FATAL: read failed: $!" unless defined $n;
return $self;
}
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::Checksum - [internal only]
=head1 DESCRIPTION
You are probably looking for L<Crypt::Checksum::CRC32> or L<Crypt::Checksum::Adler32>.
=cut

View File

@ -1,194 +0,0 @@
package Crypt::Checksum::Adler32;
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Checksum Exporter);
our %EXPORT_TAGS = ( all => [qw( adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub adler32_file { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::Adler32->new->addfile(@_)->digest }
sub adler32_file_hex { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::Adler32->new->addfile(@_)->hexdigest }
sub adler32_file_int { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::Adler32->new->addfile(@_)->intdigest }
1;
=pod
=head1 NAME
Crypt::Checksum::Adler32 - Compute Adler32 checksum
=head1 SYNOPSIS
### Functional interface:
use Crypt::Checksum::Adler32 ':all';
# calculate Adler32 checksum from string/buffer
$checksum_raw = adler32_data($data);
$checksum_hex = adler32_data_hex($data);
$checksum_int = adler32_data_int($data);
# calculate Adler32 checksum from file
$checksum_raw = adler32_file('filename.dat');
$checksum_hex = adler32_file_hex('filename.dat');
$checksum_int = adler32_file_int('filename.dat');
# calculate Adler32 checksum from filehandle
$checksum_raw = adler32_file(*FILEHANDLE);
$checksum_hex = adler32_file_hex(*FILEHANDLE);
$checksum_int = adler32_file_int(*FILEHANDLE);
### OO interface:
use Crypt::Checksum::Adler32;
$d = Crypt::Checksum::Adler32->new;
$d->add('any data');
$d->add('another data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$checksum_raw = $d->digest; # raw 4 bytes
$checksum_hex = $d->hexdigest; # hexadecimal form
$checksum_int = $d->intdigest; # 32bit unsigned integer
=head1 DESCRIPTION
Calculating Adler32 checksums.
I<Updated: v0.057>
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Checksum::Adler32 qw(adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int);
Or all of them at once:
use Crypt::Checksum::Adler32 ':all';
=head1 FUNCTIONS
=head2 adler32_data
Returns checksum as raw octects.
$checksum_raw = adler32_data('data string');
#or
$checksum_raw = adler32_data('any data', 'more data', 'even more data');
=head2 adler32_data_hex
Returns checksum as a hexadecimal string.
$checksum_hex = adler32_data_hex('data string');
#or
$checksum_hex = adler32_data_hex('any data', 'more data', 'even more data');
=head2 adler32_data_int
Returns checksum as unsigned 32bit integer.
$checksum_int = adler32_data_int('data string');
#or
$checksum_int = adler32_data_int('any data', 'more data', 'even more data');
=head2 adler32_file
Returns checksum as raw octects.
$checksum_raw = adler32_file('filename.dat');
#or
$checksum_raw = adler32_file(*FILEHANDLE);
=head2 adler32_file_hex
Returns checksum as a hexadecimal string.
$checksum_hex = adler32_file_hex('filename.dat');
#or
$checksum_hex = adler32_file_hex(*FILEHANDLE);
=head2 adler32_file_int
Returns checksum as unsigned 32bit integer.
$checksum_int = adler32_file_int('filename.dat');
#or
$checksum_int = adler32_file_int(*FILEHANDLE);
=head1 METHODS
=head2 new
Constructor, returns a reference to the checksum object.
$d = Crypt::Checksum::Adler32->new;
=head2 clone
Creates a copy of the checksum object state and returns a reference to the copy.
$d->clone();
=head2 reset
Reinitialize the checksum object state and returns a reference to the checksum object.
$d->reset();
=head2 add
All arguments are appended to the message we calculate checksum for.
The return value is the checksum object itself.
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
The content of the file (or filehandle) is appended to the message we calculate checksum for.
The return value is the checksum object itself.
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 digest
Returns the binary checksum (raw bytes).
$result_raw = $d->digest();
=head2 hexdigest
Returns the checksum encoded as a hexadecimal string.
$result_hex = $d->hexdigest();
=head2 intdigest
Returns the checksum encoded as unsigned 32bit integer.
$result_int = $d->intdigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>
=item * L<https://en.wikipedia.org/wiki/Adler-32>
=back
=cut

View File

@ -1,194 +0,0 @@
package Crypt::Checksum::CRC32;
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Checksum Exporter);
our %EXPORT_TAGS = ( all => [qw( crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub crc32_file { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::CRC32->new->addfile(@_)->digest }
sub crc32_file_hex { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::CRC32->new->addfile(@_)->hexdigest }
sub crc32_file_int { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::CRC32->new->addfile(@_)->intdigest }
1;
=pod
=head1 NAME
Crypt::Checksum::CRC32 - Compute CRC32 checksum
=head1 SYNOPSIS
### Functional interface:
use Crypt::Checksum::CRC32 ':all';
# calculate CRC32 checksum from string/buffer
$checksum_raw = crc32_data($data);
$checksum_hex = crc32_data_hex($data);
$checksum_int = crc32_data_int($data);
# calculate CRC32 checksum from file
$checksum_raw = crc32_file('filename.dat');
$checksum_hex = crc32_file_hex('filename.dat');
$checksum_int = crc32_file_int('filename.dat');
# calculate CRC32 checksum from filehandle
$checksum_raw = crc32_file(*FILEHANDLE);
$checksum_hex = crc32_file_hex(*FILEHANDLE);
$checksum_int = crc32_file_int(*FILEHANDLE);
### OO interface:
use Crypt::Checksum::CRC32;
$d = Crypt::Checksum::CRC32->new;
$d->add('any data');
$d->add('another data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$checksum_raw = $d->digest; # raw 4 bytes
$checksum_hex = $d->hexdigest; # hexadecimal form
$checksum_int = $d->intdigest; # 32bit unsigned integer
=head1 DESCRIPTION
Calculating CRC32 checksums.
I<Updated: v0.057>
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Checksum::CRC32 qw(crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int);
Or all of them at once:
use Crypt::Checksum::CRC32 ':all';
=head1 FUNCTIONS
=head2 crc32_data
Returns checksum as raw octects.
$checksum_raw = crc32_data('data string');
#or
$checksum_raw = crc32_data('any data', 'more data', 'even more data');
=head2 crc32_data_hex
Returns checksum as a hexadecimal string.
$checksum_hex = crc32_data_hex('data string');
#or
$checksum_hex = crc32_data_hex('any data', 'more data', 'even more data');
=head2 crc32_data_int
Returns checksum as unsigned 32bit integer.
$checksum_int = crc32_data_int('data string');
#or
$checksum_int = crc32_data_int('any data', 'more data', 'even more data');
=head2 crc32_file
Returns checksum as raw octects.
$checksum_raw = crc32_file('filename.dat');
#or
$checksum_raw = crc32_file(*FILEHANDLE);
=head2 crc32_file_hex
Returns checksum as a hexadecimal string.
$checksum_hex = crc32_file_hex('filename.dat');
#or
$checksum_hex = crc32_file_hex(*FILEHANDLE);
=head2 crc32_file_int
Returns checksum as unsigned 32bit integer.
$checksum_int = crc32_file_int('filename.dat');
#or
$checksum_int = crc32_file_int(*FILEHANDLE);
=head1 METHODS
=head2 new
Constructor, returns a reference to the checksum object.
$d = Crypt::Checksum::CRC32->new;
=head2 clone
Creates a copy of the checksum object state and returns a reference to the copy.
$d->clone();
=head2 reset
Reinitialize the checksum object state and returns a reference to the checksum object.
$d->reset();
=head2 add
All arguments are appended to the message we calculate checksum for.
The return value is the checksum object itself.
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
The content of the file (or filehandle) is appended to the message we calculate checksum for.
The return value is the checksum object itself.
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 digest
Returns the binary checksum (raw bytes).
$result_raw = $d->digest();
=head2 hexdigest
Returns the checksum encoded as a hexadecimal string.
$result_hex = $d->hexdigest();
=head2 intdigest
Returns the checksum encoded as unsigned 32bit integer.
$result_int = $d->intdigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>
=item * L<https://en.wikipedia.org/wiki/Cyclic_redundancy_check>
=back
=cut

View File

@ -1,155 +0,0 @@
package Crypt::Cipher;
use strict;
use warnings;
our $VERSION = '0.058_002';
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
### the following methods/functions are implemented in XS:
# - new
# - DESTROY
# - blocksize
# - decrypt
# - default_rounds
# - encrypt
# - max_keysize
# - min_keysize
sub keysize { goto \&max_keysize; } # for Crypt::CBC compatibility
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::Cipher - Generic interface to cipher functions
=head1 SYNOPSIS
#### example 1 (encrypting single block)
use Crypt::Cipher;
my $key = '...'; # length has to be valid key size for this cipher
my $c = Crypt::Cipher->new('AES', $key);
my $blocksize = $c->blocksize;
my $ciphertext = $c->encrypt('plain text block'); #encrypt 1 block
my $plaintext = $c->decrypt($ciphertext); #decrypt 1 block
### example 2 (using CBC mode)
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('AES');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
#### example 3 (compatibility with Crypt::CBC)
use Crypt::CBC;
use Crypt::Cipher;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cipher = Crypt::Cipher('AES', $key);
my $cbc = Crypt::CBC->new( -cipher=>$cipher, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
Provides an interface to various symmetric cipher algorithms.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
Constructor, returns a reference to the cipher object.
## basic scenario
$d = Crypt::Cipher->new($name, $key);
# $name = one of 'AES', 'Anubis', 'Blowfish', 'CAST5', 'Camellia', 'DES', 'DES_EDE',
# 'KASUMI', 'Khazad', 'MULTI2', 'Noekeon', 'RC2', 'RC5', 'RC6',
# 'SAFERP', 'SAFER_K128', 'SAFER_K64', 'SAFER_SK128', 'SAFER_SK64',
# 'SEED', 'Skipjack', 'Twofish', 'XTEA', 'IDEA', 'Serpent'
# simply any <NAME> for which there exists Crypt::Cipher::<NAME>
# $key = binary key (keysize should comply with selected cipher requirements)
## some of the ciphers (e.g. MULTI2, RC5, SAFER) allow one to set number of rounds
$d = Crypt::Cipher->new('MULTI2', $key, $rounds);
# $rounds = positive integer (should comply with selected cipher requirements)
=head2 encrypt
Encrypts $plaintext and returns the $ciphertext where $plaintext and $ciphertext should be of B<blocksize> bytes.
$ciphertext = $d->encrypt($plaintext);
=head2 decrypt
Decrypts $ciphertext and returns the $plaintext where $plaintext and $ciphertext should be of B<blocksize> bytes.
$plaintext = $d->encrypt($ciphertext);
=head2 keysize
Just an alias for B<max_keysize> (needed for L<Crypt::CBC|Crypt::CBC> compatibility).
=head2 max_keysize
Returns the maximal allowed key size (in bytes) for given cipher.
$d->max_keysize;
#or
Crypt::Cipher->max_keysize('AES');
#or
Crypt::Cipher::max_keysize('AES');
=head2 min_keysize
Returns the minimal allowed key size (in bytes) for given cipher.
$d->min_keysize;
#or
Crypt::Cipher->min_keysize('AES');
#or
Crypt::Cipher::min_keysize('AES');
=head2 blocksize
Returns block size (in bytes) for given cipher.
$d->blocksize;
#or
Crypt::Cipher->blocksize('AES');
#or
Crypt::Cipher::blocksize('AES');
=head2 default_rounds
Returns default number of rounds for given cipher. NOTE: only some ciphers (e.g. MULTI2, RC5, SAFER) allow one to set number of rounds via new().
$d->default_rounds;
#or
Crypt::Cipher->default_rounds('AES');
#or
Crypt::Cipher::default_rounds('AES');
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>
=item * Check subclasses like L<Crypt::Cipher::AES|Crypt::Cipher::AES>, L<Crypt::Cipher::Blowfish|Crypt::Cipher::Blowfish>, ...
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::AES;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('AES') }
sub keysize { Crypt::Cipher::keysize('AES') }
sub max_keysize { Crypt::Cipher::max_keysize('AES') }
sub min_keysize { Crypt::Cipher::min_keysize('AES') }
sub default_rounds { Crypt::Cipher::default_rounds('AES') }
1;
=pod
=head1 NAME
Crypt::Cipher::AES - Symmetric cipher AES (aka Rijndael), key size: 128/192/256 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('AES');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::AES;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::AES', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the AES cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::AES->new($key);
#or
$c = Crypt::Cipher::AES->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::AES->keysize;
#or
Crypt::Cipher::AES::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::AES->blocksize;
#or
Crypt::Cipher::AES::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::AES->max_keysize;
#or
Crypt::Cipher::AES::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::AES->min_keysize;
#or
Crypt::Cipher::AES::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::AES->default_rounds;
#or
Crypt::Cipher::AES::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Advanced_Encryption_Standard>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::Anubis;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Anubis') }
sub keysize { Crypt::Cipher::keysize('Anubis') }
sub max_keysize { Crypt::Cipher::max_keysize('Anubis') }
sub min_keysize { Crypt::Cipher::min_keysize('Anubis') }
sub default_rounds { Crypt::Cipher::default_rounds('Anubis') }
1;
=pod
=head1 NAME
Crypt::Cipher::Anubis - Symmetric cipher Anubis, key size: 128-320 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Anubis');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Anubis;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Anubis', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Anubis cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Anubis->new($key);
#or
$c = Crypt::Cipher::Anubis->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Anubis->keysize;
#or
Crypt::Cipher::Anubis::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Anubis->blocksize;
#or
Crypt::Cipher::Anubis::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Anubis->max_keysize;
#or
Crypt::Cipher::Anubis::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Anubis->min_keysize;
#or
Crypt::Cipher::Anubis::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Anubis->default_rounds;
#or
Crypt::Cipher::Anubis::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Anubis_(cipher)>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::Blowfish;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Blowfish') }
sub keysize { Crypt::Cipher::keysize('Blowfish') }
sub max_keysize { Crypt::Cipher::max_keysize('Blowfish') }
sub min_keysize { Crypt::Cipher::min_keysize('Blowfish') }
sub default_rounds { Crypt::Cipher::default_rounds('Blowfish') }
1;
=pod
=head1 NAME
Crypt::Cipher::Blowfish - Symmetric cipher Blowfish, key size: 64-448 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Blowfish');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Blowfish;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Blowfish', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Blowfish cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Blowfish->new($key);
#or
$c = Crypt::Cipher::Blowfish->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Blowfish->keysize;
#or
Crypt::Cipher::Blowfish::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Blowfish->blocksize;
#or
Crypt::Cipher::Blowfish::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Blowfish->max_keysize;
#or
Crypt::Cipher::Blowfish::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Blowfish->min_keysize;
#or
Crypt::Cipher::Blowfish::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Blowfish->default_rounds;
#or
Crypt::Cipher::Blowfish::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Blowfish_(cipher)>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::CAST5;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('CAST5') }
sub keysize { Crypt::Cipher::keysize('CAST5') }
sub max_keysize { Crypt::Cipher::max_keysize('CAST5') }
sub min_keysize { Crypt::Cipher::min_keysize('CAST5') }
sub default_rounds { Crypt::Cipher::default_rounds('CAST5') }
1;
=pod
=head1 NAME
Crypt::Cipher::CAST5 - Symmetric cipher CAST5 (aka CAST-128), key size: 40-128 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('CAST5');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::CAST5;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::CAST5', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the CAST5 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::CAST5->new($key);
#or
$c = Crypt::Cipher::CAST5->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::CAST5->keysize;
#or
Crypt::Cipher::CAST5::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::CAST5->blocksize;
#or
Crypt::Cipher::CAST5::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::CAST5->max_keysize;
#or
Crypt::Cipher::CAST5::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::CAST5->min_keysize;
#or
Crypt::Cipher::CAST5::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::CAST5->default_rounds;
#or
Crypt::Cipher::CAST5::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/CAST-128>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::Camellia;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Camellia') }
sub keysize { Crypt::Cipher::keysize('Camellia') }
sub max_keysize { Crypt::Cipher::max_keysize('Camellia') }
sub min_keysize { Crypt::Cipher::min_keysize('Camellia') }
sub default_rounds { Crypt::Cipher::default_rounds('Camellia') }
1;
=pod
=head1 NAME
Crypt::Cipher::Camellia - Symmetric cipher Camellia, key size: 128/192/256 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Camellia');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Camellia;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Camellia', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Camellia cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Camellia->new($key);
#or
$c = Crypt::Cipher::Camellia->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Camellia->keysize;
#or
Crypt::Cipher::Camellia::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Camellia->blocksize;
#or
Crypt::Cipher::Camellia::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Camellia->max_keysize;
#or
Crypt::Cipher::Camellia::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Camellia->min_keysize;
#or
Crypt::Cipher::Camellia::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Camellia->default_rounds;
#or
Crypt::Cipher::Camellia::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Camellia_(cipher)>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::DES;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('DES') }
sub keysize { Crypt::Cipher::keysize('DES') }
sub max_keysize { Crypt::Cipher::max_keysize('DES') }
sub min_keysize { Crypt::Cipher::min_keysize('DES') }
sub default_rounds { Crypt::Cipher::default_rounds('DES') }
1;
=pod
=head1 NAME
Crypt::Cipher::DES - Symmetric cipher DES, key size: 64[56] bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('DES');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::DES;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::DES', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the DES cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::DES->new($key);
#or
$c = Crypt::Cipher::DES->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::DES->keysize;
#or
Crypt::Cipher::DES::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::DES->blocksize;
#or
Crypt::Cipher::DES::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::DES->max_keysize;
#or
Crypt::Cipher::DES::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::DES->min_keysize;
#or
Crypt::Cipher::DES::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::DES->default_rounds;
#or
Crypt::Cipher::DES::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Data_Encryption_Standard>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::DES_EDE;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('DES_EDE') }
sub keysize { Crypt::Cipher::keysize('DES_EDE') }
sub max_keysize { Crypt::Cipher::max_keysize('DES_EDE') }
sub min_keysize { Crypt::Cipher::min_keysize('DES_EDE') }
sub default_rounds { Crypt::Cipher::default_rounds('DES_EDE') }
1;
=pod
=head1 NAME
Crypt::Cipher::DES_EDE - Symmetric cipher DES_EDE (aka Triple-DES, 3DES), key size: 192[168] bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('DES_EDE');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::DES_EDE;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::DES_EDE', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the DES_EDE cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::DES_EDE->new($key);
#or
$c = Crypt::Cipher::DES_EDE->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::DES_EDE->keysize;
#or
Crypt::Cipher::DES_EDE::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::DES_EDE->blocksize;
#or
Crypt::Cipher::DES_EDE::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::DES_EDE->max_keysize;
#or
Crypt::Cipher::DES_EDE::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::DES_EDE->min_keysize;
#or
Crypt::Cipher::DES_EDE::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::DES_EDE->default_rounds;
#or
Crypt::Cipher::DES_EDE::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Triple_DES>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::IDEA;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('IDEA') }
sub keysize { Crypt::Cipher::keysize('IDEA') }
sub max_keysize { Crypt::Cipher::max_keysize('IDEA') }
sub min_keysize { Crypt::Cipher::min_keysize('IDEA') }
sub default_rounds { Crypt::Cipher::default_rounds('IDEA') }
1;
=pod
=head1 NAME
Crypt::Cipher::IDEA - Symmetric cipher IDEA, key size: 128 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('IDEA');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::IDEA;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::IDEA', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the IDEA cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::IDEA->new($key);
#or
$c = Crypt::Cipher::IDEA->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::IDEA->keysize;
#or
Crypt::Cipher::IDEA::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::IDEA->blocksize;
#or
Crypt::Cipher::IDEA::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::IDEA->max_keysize;
#or
Crypt::Cipher::IDEA::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::IDEA->min_keysize;
#or
Crypt::Cipher::IDEA::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::IDEA->default_rounds;
#or
Crypt::Cipher::IDEA::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/International_Data_Encryption_Algorithm>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::KASUMI;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('KASUMI') }
sub keysize { Crypt::Cipher::keysize('KASUMI') }
sub max_keysize { Crypt::Cipher::max_keysize('KASUMI') }
sub min_keysize { Crypt::Cipher::min_keysize('KASUMI') }
sub default_rounds { Crypt::Cipher::default_rounds('KASUMI') }
1;
=pod
=head1 NAME
Crypt::Cipher::KASUMI - Symmetric cipher KASUMI, key size: 128 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('KASUMI');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::KASUMI;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::KASUMI', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the KASUMI cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::KASUMI->new($key);
#or
$c = Crypt::Cipher::KASUMI->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::KASUMI->keysize;
#or
Crypt::Cipher::KASUMI::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::KASUMI->blocksize;
#or
Crypt::Cipher::KASUMI::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::KASUMI->max_keysize;
#or
Crypt::Cipher::KASUMI::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::KASUMI->min_keysize;
#or
Crypt::Cipher::KASUMI::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::KASUMI->default_rounds;
#or
Crypt::Cipher::KASUMI::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/KASUMI_(block_cipher)>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::Khazad;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Khazad') }
sub keysize { Crypt::Cipher::keysize('Khazad') }
sub max_keysize { Crypt::Cipher::max_keysize('Khazad') }
sub min_keysize { Crypt::Cipher::min_keysize('Khazad') }
sub default_rounds { Crypt::Cipher::default_rounds('Khazad') }
1;
=pod
=head1 NAME
Crypt::Cipher::Khazad - Symmetric cipher Khazad, key size: 128 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Khazad');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Khazad;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Khazad', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Khazad cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Khazad->new($key);
#or
$c = Crypt::Cipher::Khazad->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Khazad->keysize;
#or
Crypt::Cipher::Khazad::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Khazad->blocksize;
#or
Crypt::Cipher::Khazad::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Khazad->max_keysize;
#or
Crypt::Cipher::Khazad::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Khazad->min_keysize;
#or
Crypt::Cipher::Khazad::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Khazad->default_rounds;
#or
Crypt::Cipher::Khazad::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/KHAZAD>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::MULTI2;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('MULTI2') }
sub keysize { Crypt::Cipher::keysize('MULTI2') }
sub max_keysize { Crypt::Cipher::max_keysize('MULTI2') }
sub min_keysize { Crypt::Cipher::min_keysize('MULTI2') }
sub default_rounds { Crypt::Cipher::default_rounds('MULTI2') }
1;
=pod
=head1 NAME
Crypt::Cipher::MULTI2 - Symmetric cipher MULTI2, key size: 320 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('MULTI2');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::MULTI2;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::MULTI2', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the MULTI2 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::MULTI2->new($key);
#or
$c = Crypt::Cipher::MULTI2->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::MULTI2->keysize;
#or
Crypt::Cipher::MULTI2::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::MULTI2->blocksize;
#or
Crypt::Cipher::MULTI2::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::MULTI2->max_keysize;
#or
Crypt::Cipher::MULTI2::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::MULTI2->min_keysize;
#or
Crypt::Cipher::MULTI2::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::MULTI2->default_rounds;
#or
Crypt::Cipher::MULTI2::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/MULTI2>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::Noekeon;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Noekeon') }
sub keysize { Crypt::Cipher::keysize('Noekeon') }
sub max_keysize { Crypt::Cipher::max_keysize('Noekeon') }
sub min_keysize { Crypt::Cipher::min_keysize('Noekeon') }
sub default_rounds { Crypt::Cipher::default_rounds('Noekeon') }
1;
=pod
=head1 NAME
Crypt::Cipher::Noekeon - Symmetric cipher Noekeon, key size: 128 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Noekeon');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Noekeon;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Noekeon', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Noekeon cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Noekeon->new($key);
#or
$c = Crypt::Cipher::Noekeon->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Noekeon->keysize;
#or
Crypt::Cipher::Noekeon::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Noekeon->blocksize;
#or
Crypt::Cipher::Noekeon::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Noekeon->max_keysize;
#or
Crypt::Cipher::Noekeon::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Noekeon->min_keysize;
#or
Crypt::Cipher::Noekeon::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Noekeon->default_rounds;
#or
Crypt::Cipher::Noekeon::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/NOEKEON>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::RC2;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('RC2') }
sub keysize { Crypt::Cipher::keysize('RC2') }
sub max_keysize { Crypt::Cipher::max_keysize('RC2') }
sub min_keysize { Crypt::Cipher::min_keysize('RC2') }
sub default_rounds { Crypt::Cipher::default_rounds('RC2') }
1;
=pod
=head1 NAME
Crypt::Cipher::RC2 - Symmetric cipher RC2, key size: 40-1024 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('RC2');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::RC2;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::RC2', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the RC2 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::RC2->new($key);
#or
$c = Crypt::Cipher::RC2->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::RC2->keysize;
#or
Crypt::Cipher::RC2::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::RC2->blocksize;
#or
Crypt::Cipher::RC2::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::RC2->max_keysize;
#or
Crypt::Cipher::RC2::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::RC2->min_keysize;
#or
Crypt::Cipher::RC2::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::RC2->default_rounds;
#or
Crypt::Cipher::RC2::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/RC2>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::RC5;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('RC5') }
sub keysize { Crypt::Cipher::keysize('RC5') }
sub max_keysize { Crypt::Cipher::max_keysize('RC5') }
sub min_keysize { Crypt::Cipher::min_keysize('RC5') }
sub default_rounds { Crypt::Cipher::default_rounds('RC5') }
1;
=pod
=head1 NAME
Crypt::Cipher::RC5 - Symmetric cipher RC5, key size: 64-1024 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('RC5');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::RC5;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::RC5', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the RC5 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::RC5->new($key);
#or
$c = Crypt::Cipher::RC5->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::RC5->keysize;
#or
Crypt::Cipher::RC5::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::RC5->blocksize;
#or
Crypt::Cipher::RC5::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::RC5->max_keysize;
#or
Crypt::Cipher::RC5::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::RC5->min_keysize;
#or
Crypt::Cipher::RC5::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::RC5->default_rounds;
#or
Crypt::Cipher::RC5::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/RC5>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::RC6;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('RC6') }
sub keysize { Crypt::Cipher::keysize('RC6') }
sub max_keysize { Crypt::Cipher::max_keysize('RC6') }
sub min_keysize { Crypt::Cipher::min_keysize('RC6') }
sub default_rounds { Crypt::Cipher::default_rounds('RC6') }
1;
=pod
=head1 NAME
Crypt::Cipher::RC6 - Symmetric cipher RC6, key size: 64-1024 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('RC6');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::RC6;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::RC6', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the RC6 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::RC6->new($key);
#or
$c = Crypt::Cipher::RC6->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::RC6->keysize;
#or
Crypt::Cipher::RC6::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::RC6->blocksize;
#or
Crypt::Cipher::RC6::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::RC6->max_keysize;
#or
Crypt::Cipher::RC6::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::RC6->min_keysize;
#or
Crypt::Cipher::RC6::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::RC6->default_rounds;
#or
Crypt::Cipher::RC6::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/RC6>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::SAFERP;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SAFERP') }
sub keysize { Crypt::Cipher::keysize('SAFERP') }
sub max_keysize { Crypt::Cipher::max_keysize('SAFERP') }
sub min_keysize { Crypt::Cipher::min_keysize('SAFERP') }
sub default_rounds { Crypt::Cipher::default_rounds('SAFERP') }
1;
=pod
=head1 NAME
Crypt::Cipher::SAFERP - Symmetric cipher SAFER+, key size: 128/192/256 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SAFERP');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SAFERP;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SAFERP', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SAFERP cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SAFERP->new($key);
#or
$c = Crypt::Cipher::SAFERP->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SAFERP->keysize;
#or
Crypt::Cipher::SAFERP::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SAFERP->blocksize;
#or
Crypt::Cipher::SAFERP::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SAFERP->max_keysize;
#or
Crypt::Cipher::SAFERP::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SAFERP->min_keysize;
#or
Crypt::Cipher::SAFERP::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SAFERP->default_rounds;
#or
Crypt::Cipher::SAFERP::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SAFER>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::SAFER_K128;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SAFER_K128') }
sub keysize { Crypt::Cipher::keysize('SAFER_K128') }
sub max_keysize { Crypt::Cipher::max_keysize('SAFER_K128') }
sub min_keysize { Crypt::Cipher::min_keysize('SAFER_K128') }
sub default_rounds { Crypt::Cipher::default_rounds('SAFER_K128') }
1;
=pod
=head1 NAME
Crypt::Cipher::SAFER_K128 - Symmetric cipher SAFER_K128, key size: 128 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SAFER_K128');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SAFER_K128;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SAFER_K128', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SAFER_K128 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SAFER_K128->new($key);
#or
$c = Crypt::Cipher::SAFER_K128->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SAFER_K128->keysize;
#or
Crypt::Cipher::SAFER_K128::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SAFER_K128->blocksize;
#or
Crypt::Cipher::SAFER_K128::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SAFER_K128->max_keysize;
#or
Crypt::Cipher::SAFER_K128::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SAFER_K128->min_keysize;
#or
Crypt::Cipher::SAFER_K128::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SAFER_K128->default_rounds;
#or
Crypt::Cipher::SAFER_K128::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SAFER>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::SAFER_K64;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SAFER_K64') }
sub keysize { Crypt::Cipher::keysize('SAFER_K64') }
sub max_keysize { Crypt::Cipher::max_keysize('SAFER_K64') }
sub min_keysize { Crypt::Cipher::min_keysize('SAFER_K64') }
sub default_rounds { Crypt::Cipher::default_rounds('SAFER_K64') }
1;
=pod
=head1 NAME
Crypt::Cipher::SAFER_K64 - Symmetric cipher SAFER_K64, key size: 64 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SAFER_K64');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SAFER_K64;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SAFER_K64', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SAFER_K64 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SAFER_K64->new($key);
#or
$c = Crypt::Cipher::SAFER_K64->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SAFER_K64->keysize;
#or
Crypt::Cipher::SAFER_K64::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SAFER_K64->blocksize;
#or
Crypt::Cipher::SAFER_K64::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SAFER_K64->max_keysize;
#or
Crypt::Cipher::SAFER_K64::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SAFER_K64->min_keysize;
#or
Crypt::Cipher::SAFER_K64::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SAFER_K64->default_rounds;
#or
Crypt::Cipher::SAFER_K64::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SAFER>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::SAFER_SK128;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SAFER_SK128') }
sub keysize { Crypt::Cipher::keysize('SAFER_SK128') }
sub max_keysize { Crypt::Cipher::max_keysize('SAFER_SK128') }
sub min_keysize { Crypt::Cipher::min_keysize('SAFER_SK128') }
sub default_rounds { Crypt::Cipher::default_rounds('SAFER_SK128') }
1;
=pod
=head1 NAME
Crypt::Cipher::SAFER_SK128 - Symmetric cipher SAFER_SK128, key size: 128 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SAFER_SK128');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SAFER_SK128;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SAFER_SK128', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SAFER_SK128 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SAFER_SK128->new($key);
#or
$c = Crypt::Cipher::SAFER_SK128->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SAFER_SK128->keysize;
#or
Crypt::Cipher::SAFER_SK128::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SAFER_SK128->blocksize;
#or
Crypt::Cipher::SAFER_SK128::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SAFER_SK128->max_keysize;
#or
Crypt::Cipher::SAFER_SK128::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SAFER_SK128->min_keysize;
#or
Crypt::Cipher::SAFER_SK128::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SAFER_SK128->default_rounds;
#or
Crypt::Cipher::SAFER_SK128::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SAFER>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::SAFER_SK64;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SAFER_SK64') }
sub keysize { Crypt::Cipher::keysize('SAFER_SK64') }
sub max_keysize { Crypt::Cipher::max_keysize('SAFER_SK64') }
sub min_keysize { Crypt::Cipher::min_keysize('SAFER_SK64') }
sub default_rounds { Crypt::Cipher::default_rounds('SAFER_SK64') }
1;
=pod
=head1 NAME
Crypt::Cipher::SAFER_SK64 - Symmetric cipher SAFER_SK64, key size: 64 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SAFER_SK64');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SAFER_SK64;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SAFER_SK64', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SAFER_SK64 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SAFER_SK64->new($key);
#or
$c = Crypt::Cipher::SAFER_SK64->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SAFER_SK64->keysize;
#or
Crypt::Cipher::SAFER_SK64::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SAFER_SK64->blocksize;
#or
Crypt::Cipher::SAFER_SK64::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SAFER_SK64->max_keysize;
#or
Crypt::Cipher::SAFER_SK64::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SAFER_SK64->min_keysize;
#or
Crypt::Cipher::SAFER_SK64::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SAFER_SK64->default_rounds;
#or
Crypt::Cipher::SAFER_SK64::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SAFER>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::SEED;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SEED') }
sub keysize { Crypt::Cipher::keysize('SEED') }
sub max_keysize { Crypt::Cipher::max_keysize('SEED') }
sub min_keysize { Crypt::Cipher::min_keysize('SEED') }
sub default_rounds { Crypt::Cipher::default_rounds('SEED') }
1;
=pod
=head1 NAME
Crypt::Cipher::SEED - Symmetric cipher SEED, key size: 128 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SEED');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SEED;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SEED', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SEED cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SEED->new($key);
#or
$c = Crypt::Cipher::SEED->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SEED->keysize;
#or
Crypt::Cipher::SEED::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SEED->blocksize;
#or
Crypt::Cipher::SEED::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SEED->max_keysize;
#or
Crypt::Cipher::SEED::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SEED->min_keysize;
#or
Crypt::Cipher::SEED::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SEED->default_rounds;
#or
Crypt::Cipher::SEED::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SEED>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::Serpent;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Serpent') }
sub keysize { Crypt::Cipher::keysize('Serpent') }
sub max_keysize { Crypt::Cipher::max_keysize('Serpent') }
sub min_keysize { Crypt::Cipher::min_keysize('Serpent') }
sub default_rounds { Crypt::Cipher::default_rounds('Serpent') }
1;
=pod
=head1 NAME
Crypt::Cipher::Serpent - Symmetric cipher Serpent, key size: 128/192/256 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Serpent');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Serpent;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Serpent', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Serpent cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Serpent->new($key);
#or
$c = Crypt::Cipher::Serpent->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Serpent->keysize;
#or
Crypt::Cipher::Serpent::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Serpent->blocksize;
#or
Crypt::Cipher::Serpent::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Serpent->max_keysize;
#or
Crypt::Cipher::Serpent::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Serpent->min_keysize;
#or
Crypt::Cipher::Serpent::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Serpent->default_rounds;
#or
Crypt::Cipher::Serpent::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Serpent_(cipher)>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::Skipjack;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Skipjack') }
sub keysize { Crypt::Cipher::keysize('Skipjack') }
sub max_keysize { Crypt::Cipher::max_keysize('Skipjack') }
sub min_keysize { Crypt::Cipher::min_keysize('Skipjack') }
sub default_rounds { Crypt::Cipher::default_rounds('Skipjack') }
1;
=pod
=head1 NAME
Crypt::Cipher::Skipjack - Symmetric cipher Skipjack, key size: 80 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Skipjack');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Skipjack;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Skipjack', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Skipjack cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Skipjack->new($key);
#or
$c = Crypt::Cipher::Skipjack->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Skipjack->keysize;
#or
Crypt::Cipher::Skipjack::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Skipjack->blocksize;
#or
Crypt::Cipher::Skipjack::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Skipjack->max_keysize;
#or
Crypt::Cipher::Skipjack::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Skipjack->min_keysize;
#or
Crypt::Cipher::Skipjack::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Skipjack->default_rounds;
#or
Crypt::Cipher::Skipjack::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Skipjack_(cipher)>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::Twofish;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Twofish') }
sub keysize { Crypt::Cipher::keysize('Twofish') }
sub max_keysize { Crypt::Cipher::max_keysize('Twofish') }
sub min_keysize { Crypt::Cipher::min_keysize('Twofish') }
sub default_rounds { Crypt::Cipher::default_rounds('Twofish') }
1;
=pod
=head1 NAME
Crypt::Cipher::Twofish - Symmetric cipher Twofish, key size: 128/192/256 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Twofish');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Twofish;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Twofish', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Twofish cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Twofish->new($key);
#or
$c = Crypt::Cipher::Twofish->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Twofish->keysize;
#or
Crypt::Cipher::Twofish::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Twofish->blocksize;
#or
Crypt::Cipher::Twofish::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Twofish->max_keysize;
#or
Crypt::Cipher::Twofish::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Twofish->min_keysize;
#or
Crypt::Cipher::Twofish::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Twofish->default_rounds;
#or
Crypt::Cipher::Twofish::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Twofish>
=back
=cut

View File

@ -1,118 +0,0 @@
package Crypt::Cipher::XTEA;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('XTEA') }
sub keysize { Crypt::Cipher::keysize('XTEA') }
sub max_keysize { Crypt::Cipher::max_keysize('XTEA') }
sub min_keysize { Crypt::Cipher::min_keysize('XTEA') }
sub default_rounds { Crypt::Cipher::default_rounds('XTEA') }
1;
=pod
=head1 NAME
Crypt::Cipher::XTEA - Symmetric cipher XTEA, key size: 128 bits (Crypt::CBC compliant)
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('XTEA');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::XTEA;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::XTEA', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the XTEA cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::XTEA->new($key);
#or
$c = Crypt::Cipher::XTEA->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::XTEA->keysize;
#or
Crypt::Cipher::XTEA::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::XTEA->blocksize;
#or
Crypt::Cipher::XTEA::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::XTEA->max_keysize;
#or
Crypt::Cipher::XTEA::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::XTEA->min_keysize;
#or
Crypt::Cipher::XTEA::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::XTEA->default_rounds;
#or
Crypt::Cipher::XTEA::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/XTEA>
=back
=cut

View File

@ -1,322 +0,0 @@
package Crypt::Digest;
use strict;
use warnings;
our $VERSION = '0.058_002';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
our %EXPORT_TAGS = ( all => [qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u digest_file digest_file_hex digest_file_b64 digest_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
### the following methods/functions are implemented in XS:
# - new
# - hashsize
# - clone
# - reset
# - digest
# - hexdigest
# - b64digest
# - add
# - digest_data
# - digest_data_hex
# - digest_data_b64
# - digest_data_b64u
# - DESTROY
### METHODS
sub addfile {
my ($self, $file) = @_;
my $handle;
if (ref(\$file) eq 'SCALAR') { #filename
open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
binmode($handle);
}
else { #handle
$handle = $file
}
croak "FATAL: invalid handle" unless defined $handle;
my $n;
my $buf = "";
while (($n = read($handle, $buf, 32*1024))) {
$self->add($buf)
}
croak "FATAL: read failed: $!" unless defined $n;
return $self;
}
sub CLONE_SKIP { 1 } # prevent cloning
### FUNCTIONS
sub digest_file { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Digest->new(shift)->addfile(@_)->digest }
sub digest_file_hex { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Digest->new(shift)->addfile(@_)->hexdigest }
sub digest_file_b64 { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Digest->new(shift)->addfile(@_)->b64digest }
sub digest_file_b64u { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Digest->new(shift)->addfile(@_)->b64udigest }
1;
=pod
=head1 NAME
Crypt::Digest - Generic interface to hash/digest functions
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u
digest_file digest_file_hex digest_file_b64 digest_file_b64u );
# calculate digest from string/buffer
$digest_raw = digest_data('SHA1', 'data string');
$digest_hex = digest_data_hex('SHA1', 'data string');
$digest_b64 = digest_data_b64('SHA1', 'data string');
$digest_b64u = digest_data_b64u('SHA1', 'data string');
# calculate digest from file
$digest_raw = digest_file('SHA1', 'filename.dat');
$digest_hex = digest_file_hex('SHA1', 'filename.dat');
$digest_b64 = digest_file_b64('SHA1', 'filename.dat');
$digest_b64u = digest_file_b64u('SHA1', 'filename.dat');
# calculate digest from filehandle
$digest_raw = digest_file('SHA1', *FILEHANDLE);
$digest_hex = digest_file_hex('SHA1', *FILEHANDLE);
$digest_b64 = digest_file_b64('SHA1', *FILEHANDLE);
$digest_b64u = digest_file_b64u('SHA1', *FILEHANDLE);
### OO interface:
use Crypt::Digest;
$d = Crypt::Digest->new('SHA1');
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to various hash/digest algorithms.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u
digest_file digest_file_hex digest_file_b64 digest_file_b64u );
Or all of them at once:
use Crypt::Digest ':all';
=head1 FUNCTIONS
Please note that all functions take as its first argument the algorithm name, supported values are:
'CHAES', 'MD2', 'MD4', 'MD5', 'RIPEMD128', 'RIPEMD160',
'RIPEMD256', 'RIPEMD320', 'SHA1', 'SHA224', 'SHA256',
'SHA384', 'SHA512', 'SHA512_224', 'SHA512_256', 'Tiger192', 'Whirlpool',
'SHA3_224', 'SHA3_256', 'SHA3_384', 'SHA3_512',
'BLAKE2b_160', 'BLAKE2b_256', 'BLAKE2b_384', 'BLAKE2b_512',
'BLAKE2s_128', 'BLAKE2s_160', 'BLAKE2s_224', 'BLAKE2s_256'
(simply any <NAME> for which there is Crypt::Digest::<NAME> module)
=head2 digest_data
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a binary string.
$digest_raw = digest_data('SHA1', 'data string');
#or
$digest_raw = digest_data('SHA1', 'any data', 'more data', 'even more data');
=head2 digest_data_hex
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a hexadecimal string.
$digest_hex = digest_data_hex('SHA1', 'data string');
#or
$digest_hex = digest_data_hex('SHA1', 'any data', 'more data', 'even more data');
=head2 digest_data_b64
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a Base64 string, B<with> trailing '=' padding.
$digest_b64 = digest_data_b64('SHA1', 'data string');
#or
$digest_b64 = digest_data_b64('SHA1', 'any data', 'more data', 'even more data');
=head2 digest_data_b64u
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$digest_b64url = digest_data_b64u('SHA1', 'data string');
#or
$digest_b64url = digest_data_b64u('SHA1', 'any data', 'more data', 'even more data');
=head2 digest_file
Reads file (defined by filename or filehandle) content, and returns its digest encoded as a binary string.
$digest_raw = digest_file('SHA1', 'filename.dat');
#or
$digest_raw = digest_file('SHA1', *FILEHANDLE);
=head2 digest_file_hex
Reads file (defined by filename or filehandle) content, and returns its digest encoded as a hexadecimal string.
$digest_hex = digest_file_hex('SHA1', 'filename.dat');
#or
$digest_hex = digest_file_hex('SHA1', *FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 digest_file_b64
Reads file (defined by filename or filehandle) content, and returns its digest encoded as a Base64 string, B<with> trailing '=' padding.
$digest_b64 = digest_file_b64('SHA1', 'filename.dat');
#or
$digest_b64 = digest_file_b64('SHA1', *FILEHANDLE);
=head2 digest_file_b64u
Reads file (defined by filename or filehandle) content, and returns its digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$digest_b64url = digest_file_b64u('SHA1', 'filename.dat');
#or
$digest_b64url = digest_file_b64u('SHA1', *FILEHANDLE);
=head1 METHODS
=head2 new
Constructor, returns a reference to the digest object.
$d = Crypt::Digest->new($name);
# $name could be: 'CHAES', 'MD2', 'MD4', 'MD5', 'RIPEMD128', 'RIPEMD160',
# 'RIPEMD256', 'RIPEMD320', 'SHA1', 'SHA224', 'SHA256', 'SHA384',
# 'SHA512', 'SHA512_224', 'SHA512_256', 'Tiger192', 'Whirlpool'
#
# simply any <FUNCNAME> for which there is Crypt::Digest::<FUNCNAME> module
=head2 clone
Creates a copy of the digest object state and returns a reference to the copy.
$d->clone();
=head2 reset
Reinitialize the digest object state and returns a reference to the digest object.
$d->reset();
=head2 add
All arguments are appended to the message we calculate digest for.
The return value is the digest object itself.
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
Note that all the following cases are equivalent:
# case 1
$d->add('aa', 'bb', 'cc');
# case 2
$d->add('aa');
$d->add('bb');
$d->add('cc');
# case 3
$d->add('aabbcc');
# case 4
$d->add('aa')->add('bb')->add('cc');
=head2 addfile
The content of the file (or filehandle) is appended to the message we calculate digest for.
The return value is the digest object itself.
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 add_bits
This method is available mostly for compatibility with other Digest::SOMETHING modules on CPAN, you are very unlikely to need it.
The return value is the digest object itself.
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
B<BEWARE:> It is not possible to add bits that are not a multiple of 8.
=head2 hashsize
Returns the length of calculated digest in bytes (e.g. 32 for SHA-256).
$d->hashsize;
#or
Crypt::Digest->hashsize('SHA1');
#or
Crypt::Digest::hashsize('SHA1');
=head2 digest
Returns the binary digest (raw bytes).
$result_raw = $d->digest();
=head2 hexdigest
Returns the digest encoded as a hexadecimal string.
$result_hex = $d->hexdigest();
=head2 b64digest
Returns the digest encoded as a Base64 string, B<with> trailing '=' padding (B<BEWARE:> this padding
style might differ from other Digest::<SOMETHING> modules on CPAN).
$result_b64 = $d->b64digest();
=head2 b64udigest
Returns the digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>
=item * L<Crypt::Digest|Crypt::Digest> tries to be compatible with L<Digest|Digest> interface.
=item * Check subclasses like L<Crypt::Digest::SHA1|Crypt::Digest::SHA1>, L<Crypt::Digest::MD5|Crypt::Digest::MD5>, ...
=back
=cut

View File

@ -1,225 +0,0 @@
package Crypt::Digest::BLAKE2b_160;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2b_160 blake2b_160_hex blake2b_160_b64 blake2b_160_b64u blake2b_160_file blake2b_160_file_hex blake2b_160_file_b64 blake2b_160_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2b_160') }
sub blake2b_160 { Crypt::Digest::digest_data('BLAKE2b_160', @_) }
sub blake2b_160_hex { Crypt::Digest::digest_data_hex('BLAKE2b_160', @_) }
sub blake2b_160_b64 { Crypt::Digest::digest_data_b64('BLAKE2b_160', @_) }
sub blake2b_160_b64u { Crypt::Digest::digest_data_b64u('BLAKE2b_160', @_) }
sub blake2b_160_file { Crypt::Digest::digest_file('BLAKE2b_160', @_) }
sub blake2b_160_file_hex { Crypt::Digest::digest_file_hex('BLAKE2b_160', @_) }
sub blake2b_160_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2b_160', @_) }
sub blake2b_160_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2b_160', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2b_160 - Hash function BLAKE2b [size: 160 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2b_160 qw( blake2b_160 blake2b_160_hex blake2b_160_b64 blake2b_160_b64u
blake2b_160_file blake2b_160_file_hex blake2b_160_file_b64 blake2b_160_file_b64u );
# calculate digest from string/buffer
$blake2b_160_raw = blake2b_160('data string');
$blake2b_160_hex = blake2b_160_hex('data string');
$blake2b_160_b64 = blake2b_160_b64('data string');
$blake2b_160_b64u = blake2b_160_b64u('data string');
# calculate digest from file
$blake2b_160_raw = blake2b_160_file('filename.dat');
$blake2b_160_hex = blake2b_160_file_hex('filename.dat');
$blake2b_160_b64 = blake2b_160_file_b64('filename.dat');
$blake2b_160_b64u = blake2b_160_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2b_160_raw = blake2b_160_file(*FILEHANDLE);
$blake2b_160_hex = blake2b_160_file_hex(*FILEHANDLE);
$blake2b_160_b64 = blake2b_160_file_b64(*FILEHANDLE);
$blake2b_160_b64u = blake2b_160_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2b_160;
$d = Crypt::Digest::BLAKE2b_160->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2b_160 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2b_160 qw(blake2b_160 blake2b_160_hex blake2b_160_b64 blake2b_160_b64u
blake2b_160_file blake2b_160_file_hex blake2b_160_file_b64 blake2b_160_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2b_160 ':all';
=head1 FUNCTIONS
=head2 blake2b_160
Logically joins all arguments into a single string, and returns its BLAKE2b_160 digest encoded as a binary string.
$blake2b_160_raw = blake2b_160('data string');
#or
$blake2b_160_raw = blake2b_160('any data', 'more data', 'even more data');
=head2 blake2b_160_hex
Logically joins all arguments into a single string, and returns its BLAKE2b_160 digest encoded as a hexadecimal string.
$blake2b_160_hex = blake2b_160_hex('data string');
#or
$blake2b_160_hex = blake2b_160_hex('any data', 'more data', 'even more data');
=head2 blake2b_160_b64
Logically joins all arguments into a single string, and returns its BLAKE2b_160 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_160_b64 = blake2b_160_b64('data string');
#or
$blake2b_160_b64 = blake2b_160_b64('any data', 'more data', 'even more data');
=head2 blake2b_160_b64u
Logically joins all arguments into a single string, and returns its BLAKE2b_160 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_160_b64url = blake2b_160_b64u('data string');
#or
$blake2b_160_b64url = blake2b_160_b64u('any data', 'more data', 'even more data');
=head2 blake2b_160_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_160 digest encoded as a binary string.
$blake2b_160_raw = blake2b_160_file('filename.dat');
#or
$blake2b_160_raw = blake2b_160_file(*FILEHANDLE);
=head2 blake2b_160_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_160 digest encoded as a hexadecimal string.
$blake2b_160_hex = blake2b_160_file_hex('filename.dat');
#or
$blake2b_160_hex = blake2b_160_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2b_160_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_160 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_160_b64 = blake2b_160_file_b64('filename.dat');
#or
$blake2b_160_b64 = blake2b_160_file_b64(*FILEHANDLE);
=head2 blake2b_160_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_160 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_160_b64url = blake2b_160_file_b64u('filename.dat');
#or
$blake2b_160_b64url = blake2b_160_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2b_160->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2b_160->hashsize();
#or
Crypt::Digest::BLAKE2b_160::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@ -1,225 +0,0 @@
package Crypt::Digest::BLAKE2b_256;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2b_256 blake2b_256_hex blake2b_256_b64 blake2b_256_b64u blake2b_256_file blake2b_256_file_hex blake2b_256_file_b64 blake2b_256_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2b_256') }
sub blake2b_256 { Crypt::Digest::digest_data('BLAKE2b_256', @_) }
sub blake2b_256_hex { Crypt::Digest::digest_data_hex('BLAKE2b_256', @_) }
sub blake2b_256_b64 { Crypt::Digest::digest_data_b64('BLAKE2b_256', @_) }
sub blake2b_256_b64u { Crypt::Digest::digest_data_b64u('BLAKE2b_256', @_) }
sub blake2b_256_file { Crypt::Digest::digest_file('BLAKE2b_256', @_) }
sub blake2b_256_file_hex { Crypt::Digest::digest_file_hex('BLAKE2b_256', @_) }
sub blake2b_256_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2b_256', @_) }
sub blake2b_256_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2b_256', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2b_256 - Hash function BLAKE2b [size: 256 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2b_256 qw( blake2b_256 blake2b_256_hex blake2b_256_b64 blake2b_256_b64u
blake2b_256_file blake2b_256_file_hex blake2b_256_file_b64 blake2b_256_file_b64u );
# calculate digest from string/buffer
$blake2b_256_raw = blake2b_256('data string');
$blake2b_256_hex = blake2b_256_hex('data string');
$blake2b_256_b64 = blake2b_256_b64('data string');
$blake2b_256_b64u = blake2b_256_b64u('data string');
# calculate digest from file
$blake2b_256_raw = blake2b_256_file('filename.dat');
$blake2b_256_hex = blake2b_256_file_hex('filename.dat');
$blake2b_256_b64 = blake2b_256_file_b64('filename.dat');
$blake2b_256_b64u = blake2b_256_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2b_256_raw = blake2b_256_file(*FILEHANDLE);
$blake2b_256_hex = blake2b_256_file_hex(*FILEHANDLE);
$blake2b_256_b64 = blake2b_256_file_b64(*FILEHANDLE);
$blake2b_256_b64u = blake2b_256_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2b_256;
$d = Crypt::Digest::BLAKE2b_256->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2b_256 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2b_256 qw(blake2b_256 blake2b_256_hex blake2b_256_b64 blake2b_256_b64u
blake2b_256_file blake2b_256_file_hex blake2b_256_file_b64 blake2b_256_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2b_256 ':all';
=head1 FUNCTIONS
=head2 blake2b_256
Logically joins all arguments into a single string, and returns its BLAKE2b_256 digest encoded as a binary string.
$blake2b_256_raw = blake2b_256('data string');
#or
$blake2b_256_raw = blake2b_256('any data', 'more data', 'even more data');
=head2 blake2b_256_hex
Logically joins all arguments into a single string, and returns its BLAKE2b_256 digest encoded as a hexadecimal string.
$blake2b_256_hex = blake2b_256_hex('data string');
#or
$blake2b_256_hex = blake2b_256_hex('any data', 'more data', 'even more data');
=head2 blake2b_256_b64
Logically joins all arguments into a single string, and returns its BLAKE2b_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_256_b64 = blake2b_256_b64('data string');
#or
$blake2b_256_b64 = blake2b_256_b64('any data', 'more data', 'even more data');
=head2 blake2b_256_b64u
Logically joins all arguments into a single string, and returns its BLAKE2b_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_256_b64url = blake2b_256_b64u('data string');
#or
$blake2b_256_b64url = blake2b_256_b64u('any data', 'more data', 'even more data');
=head2 blake2b_256_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_256 digest encoded as a binary string.
$blake2b_256_raw = blake2b_256_file('filename.dat');
#or
$blake2b_256_raw = blake2b_256_file(*FILEHANDLE);
=head2 blake2b_256_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_256 digest encoded as a hexadecimal string.
$blake2b_256_hex = blake2b_256_file_hex('filename.dat');
#or
$blake2b_256_hex = blake2b_256_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2b_256_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_256_b64 = blake2b_256_file_b64('filename.dat');
#or
$blake2b_256_b64 = blake2b_256_file_b64(*FILEHANDLE);
=head2 blake2b_256_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_256_b64url = blake2b_256_file_b64u('filename.dat');
#or
$blake2b_256_b64url = blake2b_256_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2b_256->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2b_256->hashsize();
#or
Crypt::Digest::BLAKE2b_256::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@ -1,225 +0,0 @@
package Crypt::Digest::BLAKE2b_384;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2b_384 blake2b_384_hex blake2b_384_b64 blake2b_384_b64u blake2b_384_file blake2b_384_file_hex blake2b_384_file_b64 blake2b_384_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2b_384') }
sub blake2b_384 { Crypt::Digest::digest_data('BLAKE2b_384', @_) }
sub blake2b_384_hex { Crypt::Digest::digest_data_hex('BLAKE2b_384', @_) }
sub blake2b_384_b64 { Crypt::Digest::digest_data_b64('BLAKE2b_384', @_) }
sub blake2b_384_b64u { Crypt::Digest::digest_data_b64u('BLAKE2b_384', @_) }
sub blake2b_384_file { Crypt::Digest::digest_file('BLAKE2b_384', @_) }
sub blake2b_384_file_hex { Crypt::Digest::digest_file_hex('BLAKE2b_384', @_) }
sub blake2b_384_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2b_384', @_) }
sub blake2b_384_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2b_384', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2b_384 - Hash function BLAKE2b [size: 384 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2b_384 qw( blake2b_384 blake2b_384_hex blake2b_384_b64 blake2b_384_b64u
blake2b_384_file blake2b_384_file_hex blake2b_384_file_b64 blake2b_384_file_b64u );
# calculate digest from string/buffer
$blake2b_384_raw = blake2b_384('data string');
$blake2b_384_hex = blake2b_384_hex('data string');
$blake2b_384_b64 = blake2b_384_b64('data string');
$blake2b_384_b64u = blake2b_384_b64u('data string');
# calculate digest from file
$blake2b_384_raw = blake2b_384_file('filename.dat');
$blake2b_384_hex = blake2b_384_file_hex('filename.dat');
$blake2b_384_b64 = blake2b_384_file_b64('filename.dat');
$blake2b_384_b64u = blake2b_384_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2b_384_raw = blake2b_384_file(*FILEHANDLE);
$blake2b_384_hex = blake2b_384_file_hex(*FILEHANDLE);
$blake2b_384_b64 = blake2b_384_file_b64(*FILEHANDLE);
$blake2b_384_b64u = blake2b_384_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2b_384;
$d = Crypt::Digest::BLAKE2b_384->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2b_384 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2b_384 qw(blake2b_384 blake2b_384_hex blake2b_384_b64 blake2b_384_b64u
blake2b_384_file blake2b_384_file_hex blake2b_384_file_b64 blake2b_384_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2b_384 ':all';
=head1 FUNCTIONS
=head2 blake2b_384
Logically joins all arguments into a single string, and returns its BLAKE2b_384 digest encoded as a binary string.
$blake2b_384_raw = blake2b_384('data string');
#or
$blake2b_384_raw = blake2b_384('any data', 'more data', 'even more data');
=head2 blake2b_384_hex
Logically joins all arguments into a single string, and returns its BLAKE2b_384 digest encoded as a hexadecimal string.
$blake2b_384_hex = blake2b_384_hex('data string');
#or
$blake2b_384_hex = blake2b_384_hex('any data', 'more data', 'even more data');
=head2 blake2b_384_b64
Logically joins all arguments into a single string, and returns its BLAKE2b_384 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_384_b64 = blake2b_384_b64('data string');
#or
$blake2b_384_b64 = blake2b_384_b64('any data', 'more data', 'even more data');
=head2 blake2b_384_b64u
Logically joins all arguments into a single string, and returns its BLAKE2b_384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_384_b64url = blake2b_384_b64u('data string');
#or
$blake2b_384_b64url = blake2b_384_b64u('any data', 'more data', 'even more data');
=head2 blake2b_384_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_384 digest encoded as a binary string.
$blake2b_384_raw = blake2b_384_file('filename.dat');
#or
$blake2b_384_raw = blake2b_384_file(*FILEHANDLE);
=head2 blake2b_384_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_384 digest encoded as a hexadecimal string.
$blake2b_384_hex = blake2b_384_file_hex('filename.dat');
#or
$blake2b_384_hex = blake2b_384_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2b_384_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_384 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_384_b64 = blake2b_384_file_b64('filename.dat');
#or
$blake2b_384_b64 = blake2b_384_file_b64(*FILEHANDLE);
=head2 blake2b_384_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_384_b64url = blake2b_384_file_b64u('filename.dat');
#or
$blake2b_384_b64url = blake2b_384_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2b_384->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2b_384->hashsize();
#or
Crypt::Digest::BLAKE2b_384::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@ -1,225 +0,0 @@
package Crypt::Digest::BLAKE2b_512;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2b_512 blake2b_512_hex blake2b_512_b64 blake2b_512_b64u blake2b_512_file blake2b_512_file_hex blake2b_512_file_b64 blake2b_512_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2b_512') }
sub blake2b_512 { Crypt::Digest::digest_data('BLAKE2b_512', @_) }
sub blake2b_512_hex { Crypt::Digest::digest_data_hex('BLAKE2b_512', @_) }
sub blake2b_512_b64 { Crypt::Digest::digest_data_b64('BLAKE2b_512', @_) }
sub blake2b_512_b64u { Crypt::Digest::digest_data_b64u('BLAKE2b_512', @_) }
sub blake2b_512_file { Crypt::Digest::digest_file('BLAKE2b_512', @_) }
sub blake2b_512_file_hex { Crypt::Digest::digest_file_hex('BLAKE2b_512', @_) }
sub blake2b_512_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2b_512', @_) }
sub blake2b_512_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2b_512', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2b_512 - Hash function BLAKE2b [size: 512 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2b_512 qw( blake2b_512 blake2b_512_hex blake2b_512_b64 blake2b_512_b64u
blake2b_512_file blake2b_512_file_hex blake2b_512_file_b64 blake2b_512_file_b64u );
# calculate digest from string/buffer
$blake2b_512_raw = blake2b_512('data string');
$blake2b_512_hex = blake2b_512_hex('data string');
$blake2b_512_b64 = blake2b_512_b64('data string');
$blake2b_512_b64u = blake2b_512_b64u('data string');
# calculate digest from file
$blake2b_512_raw = blake2b_512_file('filename.dat');
$blake2b_512_hex = blake2b_512_file_hex('filename.dat');
$blake2b_512_b64 = blake2b_512_file_b64('filename.dat');
$blake2b_512_b64u = blake2b_512_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2b_512_raw = blake2b_512_file(*FILEHANDLE);
$blake2b_512_hex = blake2b_512_file_hex(*FILEHANDLE);
$blake2b_512_b64 = blake2b_512_file_b64(*FILEHANDLE);
$blake2b_512_b64u = blake2b_512_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2b_512;
$d = Crypt::Digest::BLAKE2b_512->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2b_512 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2b_512 qw(blake2b_512 blake2b_512_hex blake2b_512_b64 blake2b_512_b64u
blake2b_512_file blake2b_512_file_hex blake2b_512_file_b64 blake2b_512_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2b_512 ':all';
=head1 FUNCTIONS
=head2 blake2b_512
Logically joins all arguments into a single string, and returns its BLAKE2b_512 digest encoded as a binary string.
$blake2b_512_raw = blake2b_512('data string');
#or
$blake2b_512_raw = blake2b_512('any data', 'more data', 'even more data');
=head2 blake2b_512_hex
Logically joins all arguments into a single string, and returns its BLAKE2b_512 digest encoded as a hexadecimal string.
$blake2b_512_hex = blake2b_512_hex('data string');
#or
$blake2b_512_hex = blake2b_512_hex('any data', 'more data', 'even more data');
=head2 blake2b_512_b64
Logically joins all arguments into a single string, and returns its BLAKE2b_512 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_512_b64 = blake2b_512_b64('data string');
#or
$blake2b_512_b64 = blake2b_512_b64('any data', 'more data', 'even more data');
=head2 blake2b_512_b64u
Logically joins all arguments into a single string, and returns its BLAKE2b_512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_512_b64url = blake2b_512_b64u('data string');
#or
$blake2b_512_b64url = blake2b_512_b64u('any data', 'more data', 'even more data');
=head2 blake2b_512_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_512 digest encoded as a binary string.
$blake2b_512_raw = blake2b_512_file('filename.dat');
#or
$blake2b_512_raw = blake2b_512_file(*FILEHANDLE);
=head2 blake2b_512_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_512 digest encoded as a hexadecimal string.
$blake2b_512_hex = blake2b_512_file_hex('filename.dat');
#or
$blake2b_512_hex = blake2b_512_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2b_512_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_512 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_512_b64 = blake2b_512_file_b64('filename.dat');
#or
$blake2b_512_b64 = blake2b_512_file_b64(*FILEHANDLE);
=head2 blake2b_512_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_512_b64url = blake2b_512_file_b64u('filename.dat');
#or
$blake2b_512_b64url = blake2b_512_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2b_512->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2b_512->hashsize();
#or
Crypt::Digest::BLAKE2b_512::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@ -1,225 +0,0 @@
package Crypt::Digest::BLAKE2s_128;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2s_128 blake2s_128_hex blake2s_128_b64 blake2s_128_b64u blake2s_128_file blake2s_128_file_hex blake2s_128_file_b64 blake2s_128_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2s_128') }
sub blake2s_128 { Crypt::Digest::digest_data('BLAKE2s_128', @_) }
sub blake2s_128_hex { Crypt::Digest::digest_data_hex('BLAKE2s_128', @_) }
sub blake2s_128_b64 { Crypt::Digest::digest_data_b64('BLAKE2s_128', @_) }
sub blake2s_128_b64u { Crypt::Digest::digest_data_b64u('BLAKE2s_128', @_) }
sub blake2s_128_file { Crypt::Digest::digest_file('BLAKE2s_128', @_) }
sub blake2s_128_file_hex { Crypt::Digest::digest_file_hex('BLAKE2s_128', @_) }
sub blake2s_128_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2s_128', @_) }
sub blake2s_128_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2s_128', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2s_128 - Hash function BLAKE2s [size: 128 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2s_128 qw( blake2s_128 blake2s_128_hex blake2s_128_b64 blake2s_128_b64u
blake2s_128_file blake2s_128_file_hex blake2s_128_file_b64 blake2s_128_file_b64u );
# calculate digest from string/buffer
$blake2s_128_raw = blake2s_128('data string');
$blake2s_128_hex = blake2s_128_hex('data string');
$blake2s_128_b64 = blake2s_128_b64('data string');
$blake2s_128_b64u = blake2s_128_b64u('data string');
# calculate digest from file
$blake2s_128_raw = blake2s_128_file('filename.dat');
$blake2s_128_hex = blake2s_128_file_hex('filename.dat');
$blake2s_128_b64 = blake2s_128_file_b64('filename.dat');
$blake2s_128_b64u = blake2s_128_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2s_128_raw = blake2s_128_file(*FILEHANDLE);
$blake2s_128_hex = blake2s_128_file_hex(*FILEHANDLE);
$blake2s_128_b64 = blake2s_128_file_b64(*FILEHANDLE);
$blake2s_128_b64u = blake2s_128_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2s_128;
$d = Crypt::Digest::BLAKE2s_128->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2s_128 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2s_128 qw(blake2s_128 blake2s_128_hex blake2s_128_b64 blake2s_128_b64u
blake2s_128_file blake2s_128_file_hex blake2s_128_file_b64 blake2s_128_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2s_128 ':all';
=head1 FUNCTIONS
=head2 blake2s_128
Logically joins all arguments into a single string, and returns its BLAKE2s_128 digest encoded as a binary string.
$blake2s_128_raw = blake2s_128('data string');
#or
$blake2s_128_raw = blake2s_128('any data', 'more data', 'even more data');
=head2 blake2s_128_hex
Logically joins all arguments into a single string, and returns its BLAKE2s_128 digest encoded as a hexadecimal string.
$blake2s_128_hex = blake2s_128_hex('data string');
#or
$blake2s_128_hex = blake2s_128_hex('any data', 'more data', 'even more data');
=head2 blake2s_128_b64
Logically joins all arguments into a single string, and returns its BLAKE2s_128 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_128_b64 = blake2s_128_b64('data string');
#or
$blake2s_128_b64 = blake2s_128_b64('any data', 'more data', 'even more data');
=head2 blake2s_128_b64u
Logically joins all arguments into a single string, and returns its BLAKE2s_128 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_128_b64url = blake2s_128_b64u('data string');
#or
$blake2s_128_b64url = blake2s_128_b64u('any data', 'more data', 'even more data');
=head2 blake2s_128_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_128 digest encoded as a binary string.
$blake2s_128_raw = blake2s_128_file('filename.dat');
#or
$blake2s_128_raw = blake2s_128_file(*FILEHANDLE);
=head2 blake2s_128_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_128 digest encoded as a hexadecimal string.
$blake2s_128_hex = blake2s_128_file_hex('filename.dat');
#or
$blake2s_128_hex = blake2s_128_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2s_128_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_128 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_128_b64 = blake2s_128_file_b64('filename.dat');
#or
$blake2s_128_b64 = blake2s_128_file_b64(*FILEHANDLE);
=head2 blake2s_128_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_128 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_128_b64url = blake2s_128_file_b64u('filename.dat');
#or
$blake2s_128_b64url = blake2s_128_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2s_128->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2s_128->hashsize();
#or
Crypt::Digest::BLAKE2s_128::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@ -1,225 +0,0 @@
package Crypt::Digest::BLAKE2s_160;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2s_160') }
sub blake2s_160 { Crypt::Digest::digest_data('BLAKE2s_160', @_) }
sub blake2s_160_hex { Crypt::Digest::digest_data_hex('BLAKE2s_160', @_) }
sub blake2s_160_b64 { Crypt::Digest::digest_data_b64('BLAKE2s_160', @_) }
sub blake2s_160_b64u { Crypt::Digest::digest_data_b64u('BLAKE2s_160', @_) }
sub blake2s_160_file { Crypt::Digest::digest_file('BLAKE2s_160', @_) }
sub blake2s_160_file_hex { Crypt::Digest::digest_file_hex('BLAKE2s_160', @_) }
sub blake2s_160_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2s_160', @_) }
sub blake2s_160_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2s_160', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2s_160 - Hash function BLAKE2s [size: 160 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2s_160 qw( blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u
blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u );
# calculate digest from string/buffer
$blake2s_160_raw = blake2s_160('data string');
$blake2s_160_hex = blake2s_160_hex('data string');
$blake2s_160_b64 = blake2s_160_b64('data string');
$blake2s_160_b64u = blake2s_160_b64u('data string');
# calculate digest from file
$blake2s_160_raw = blake2s_160_file('filename.dat');
$blake2s_160_hex = blake2s_160_file_hex('filename.dat');
$blake2s_160_b64 = blake2s_160_file_b64('filename.dat');
$blake2s_160_b64u = blake2s_160_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2s_160_raw = blake2s_160_file(*FILEHANDLE);
$blake2s_160_hex = blake2s_160_file_hex(*FILEHANDLE);
$blake2s_160_b64 = blake2s_160_file_b64(*FILEHANDLE);
$blake2s_160_b64u = blake2s_160_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2s_160;
$d = Crypt::Digest::BLAKE2s_160->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2s_160 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2s_160 qw(blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u
blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2s_160 ':all';
=head1 FUNCTIONS
=head2 blake2s_160
Logically joins all arguments into a single string, and returns its BLAKE2s_160 digest encoded as a binary string.
$blake2s_160_raw = blake2s_160('data string');
#or
$blake2s_160_raw = blake2s_160('any data', 'more data', 'even more data');
=head2 blake2s_160_hex
Logically joins all arguments into a single string, and returns its BLAKE2s_160 digest encoded as a hexadecimal string.
$blake2s_160_hex = blake2s_160_hex('data string');
#or
$blake2s_160_hex = blake2s_160_hex('any data', 'more data', 'even more data');
=head2 blake2s_160_b64
Logically joins all arguments into a single string, and returns its BLAKE2s_160 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_160_b64 = blake2s_160_b64('data string');
#or
$blake2s_160_b64 = blake2s_160_b64('any data', 'more data', 'even more data');
=head2 blake2s_160_b64u
Logically joins all arguments into a single string, and returns its BLAKE2s_160 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_160_b64url = blake2s_160_b64u('data string');
#or
$blake2s_160_b64url = blake2s_160_b64u('any data', 'more data', 'even more data');
=head2 blake2s_160_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_160 digest encoded as a binary string.
$blake2s_160_raw = blake2s_160_file('filename.dat');
#or
$blake2s_160_raw = blake2s_160_file(*FILEHANDLE);
=head2 blake2s_160_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_160 digest encoded as a hexadecimal string.
$blake2s_160_hex = blake2s_160_file_hex('filename.dat');
#or
$blake2s_160_hex = blake2s_160_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2s_160_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_160 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_160_b64 = blake2s_160_file_b64('filename.dat');
#or
$blake2s_160_b64 = blake2s_160_file_b64(*FILEHANDLE);
=head2 blake2s_160_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_160 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_160_b64url = blake2s_160_file_b64u('filename.dat');
#or
$blake2s_160_b64url = blake2s_160_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2s_160->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2s_160->hashsize();
#or
Crypt::Digest::BLAKE2s_160::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@ -1,225 +0,0 @@
package Crypt::Digest::BLAKE2s_224;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2s_224') }
sub blake2s_224 { Crypt::Digest::digest_data('BLAKE2s_224', @_) }
sub blake2s_224_hex { Crypt::Digest::digest_data_hex('BLAKE2s_224', @_) }
sub blake2s_224_b64 { Crypt::Digest::digest_data_b64('BLAKE2s_224', @_) }
sub blake2s_224_b64u { Crypt::Digest::digest_data_b64u('BLAKE2s_224', @_) }
sub blake2s_224_file { Crypt::Digest::digest_file('BLAKE2s_224', @_) }
sub blake2s_224_file_hex { Crypt::Digest::digest_file_hex('BLAKE2s_224', @_) }
sub blake2s_224_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2s_224', @_) }
sub blake2s_224_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2s_224', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2s_224 - Hash function BLAKE2s [size: 224 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2s_224 qw( blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u
blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u );
# calculate digest from string/buffer
$blake2s_224_raw = blake2s_224('data string');
$blake2s_224_hex = blake2s_224_hex('data string');
$blake2s_224_b64 = blake2s_224_b64('data string');
$blake2s_224_b64u = blake2s_224_b64u('data string');
# calculate digest from file
$blake2s_224_raw = blake2s_224_file('filename.dat');
$blake2s_224_hex = blake2s_224_file_hex('filename.dat');
$blake2s_224_b64 = blake2s_224_file_b64('filename.dat');
$blake2s_224_b64u = blake2s_224_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2s_224_raw = blake2s_224_file(*FILEHANDLE);
$blake2s_224_hex = blake2s_224_file_hex(*FILEHANDLE);
$blake2s_224_b64 = blake2s_224_file_b64(*FILEHANDLE);
$blake2s_224_b64u = blake2s_224_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2s_224;
$d = Crypt::Digest::BLAKE2s_224->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2s_224 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2s_224 qw(blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u
blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2s_224 ':all';
=head1 FUNCTIONS
=head2 blake2s_224
Logically joins all arguments into a single string, and returns its BLAKE2s_224 digest encoded as a binary string.
$blake2s_224_raw = blake2s_224('data string');
#or
$blake2s_224_raw = blake2s_224('any data', 'more data', 'even more data');
=head2 blake2s_224_hex
Logically joins all arguments into a single string, and returns its BLAKE2s_224 digest encoded as a hexadecimal string.
$blake2s_224_hex = blake2s_224_hex('data string');
#or
$blake2s_224_hex = blake2s_224_hex('any data', 'more data', 'even more data');
=head2 blake2s_224_b64
Logically joins all arguments into a single string, and returns its BLAKE2s_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_224_b64 = blake2s_224_b64('data string');
#or
$blake2s_224_b64 = blake2s_224_b64('any data', 'more data', 'even more data');
=head2 blake2s_224_b64u
Logically joins all arguments into a single string, and returns its BLAKE2s_224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_224_b64url = blake2s_224_b64u('data string');
#or
$blake2s_224_b64url = blake2s_224_b64u('any data', 'more data', 'even more data');
=head2 blake2s_224_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_224 digest encoded as a binary string.
$blake2s_224_raw = blake2s_224_file('filename.dat');
#or
$blake2s_224_raw = blake2s_224_file(*FILEHANDLE);
=head2 blake2s_224_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_224 digest encoded as a hexadecimal string.
$blake2s_224_hex = blake2s_224_file_hex('filename.dat');
#or
$blake2s_224_hex = blake2s_224_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2s_224_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_224_b64 = blake2s_224_file_b64('filename.dat');
#or
$blake2s_224_b64 = blake2s_224_file_b64(*FILEHANDLE);
=head2 blake2s_224_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_224_b64url = blake2s_224_file_b64u('filename.dat');
#or
$blake2s_224_b64url = blake2s_224_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2s_224->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2s_224->hashsize();
#or
Crypt::Digest::BLAKE2s_224::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@ -1,225 +0,0 @@
package Crypt::Digest::BLAKE2s_256;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2s_256 blake2s_256_hex blake2s_256_b64 blake2s_256_b64u blake2s_256_file blake2s_256_file_hex blake2s_256_file_b64 blake2s_256_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2s_256') }
sub blake2s_256 { Crypt::Digest::digest_data('BLAKE2s_256', @_) }
sub blake2s_256_hex { Crypt::Digest::digest_data_hex('BLAKE2s_256', @_) }
sub blake2s_256_b64 { Crypt::Digest::digest_data_b64('BLAKE2s_256', @_) }
sub blake2s_256_b64u { Crypt::Digest::digest_data_b64u('BLAKE2s_256', @_) }
sub blake2s_256_file { Crypt::Digest::digest_file('BLAKE2s_256', @_) }
sub blake2s_256_file_hex { Crypt::Digest::digest_file_hex('BLAKE2s_256', @_) }
sub blake2s_256_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2s_256', @_) }
sub blake2s_256_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2s_256', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2s_256 - Hash function BLAKE2s [size: 256 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2s_256 qw( blake2s_256 blake2s_256_hex blake2s_256_b64 blake2s_256_b64u
blake2s_256_file blake2s_256_file_hex blake2s_256_file_b64 blake2s_256_file_b64u );
# calculate digest from string/buffer
$blake2s_256_raw = blake2s_256('data string');
$blake2s_256_hex = blake2s_256_hex('data string');
$blake2s_256_b64 = blake2s_256_b64('data string');
$blake2s_256_b64u = blake2s_256_b64u('data string');
# calculate digest from file
$blake2s_256_raw = blake2s_256_file('filename.dat');
$blake2s_256_hex = blake2s_256_file_hex('filename.dat');
$blake2s_256_b64 = blake2s_256_file_b64('filename.dat');
$blake2s_256_b64u = blake2s_256_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2s_256_raw = blake2s_256_file(*FILEHANDLE);
$blake2s_256_hex = blake2s_256_file_hex(*FILEHANDLE);
$blake2s_256_b64 = blake2s_256_file_b64(*FILEHANDLE);
$blake2s_256_b64u = blake2s_256_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2s_256;
$d = Crypt::Digest::BLAKE2s_256->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2s_256 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2s_256 qw(blake2s_256 blake2s_256_hex blake2s_256_b64 blake2s_256_b64u
blake2s_256_file blake2s_256_file_hex blake2s_256_file_b64 blake2s_256_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2s_256 ':all';
=head1 FUNCTIONS
=head2 blake2s_256
Logically joins all arguments into a single string, and returns its BLAKE2s_256 digest encoded as a binary string.
$blake2s_256_raw = blake2s_256('data string');
#or
$blake2s_256_raw = blake2s_256('any data', 'more data', 'even more data');
=head2 blake2s_256_hex
Logically joins all arguments into a single string, and returns its BLAKE2s_256 digest encoded as a hexadecimal string.
$blake2s_256_hex = blake2s_256_hex('data string');
#or
$blake2s_256_hex = blake2s_256_hex('any data', 'more data', 'even more data');
=head2 blake2s_256_b64
Logically joins all arguments into a single string, and returns its BLAKE2s_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_256_b64 = blake2s_256_b64('data string');
#or
$blake2s_256_b64 = blake2s_256_b64('any data', 'more data', 'even more data');
=head2 blake2s_256_b64u
Logically joins all arguments into a single string, and returns its BLAKE2s_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_256_b64url = blake2s_256_b64u('data string');
#or
$blake2s_256_b64url = blake2s_256_b64u('any data', 'more data', 'even more data');
=head2 blake2s_256_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_256 digest encoded as a binary string.
$blake2s_256_raw = blake2s_256_file('filename.dat');
#or
$blake2s_256_raw = blake2s_256_file(*FILEHANDLE);
=head2 blake2s_256_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_256 digest encoded as a hexadecimal string.
$blake2s_256_hex = blake2s_256_file_hex('filename.dat');
#or
$blake2s_256_hex = blake2s_256_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2s_256_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_256_b64 = blake2s_256_file_b64('filename.dat');
#or
$blake2s_256_b64 = blake2s_256_file_b64(*FILEHANDLE);
=head2 blake2s_256_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_256_b64url = blake2s_256_file_b64u('filename.dat');
#or
$blake2s_256_b64url = blake2s_256_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2s_256->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2s_256->hashsize();
#or
Crypt::Digest::BLAKE2s_256::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@ -1,223 +0,0 @@
package Crypt::Digest::CHAES;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( chaes chaes_hex chaes_b64 chaes_b64u chaes_file chaes_file_hex chaes_file_b64 chaes_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('CHAES') }
sub chaes { Crypt::Digest::digest_data('CHAES', @_) }
sub chaes_hex { Crypt::Digest::digest_data_hex('CHAES', @_) }
sub chaes_b64 { Crypt::Digest::digest_data_b64('CHAES', @_) }
sub chaes_b64u { Crypt::Digest::digest_data_b64u('CHAES', @_) }
sub chaes_file { Crypt::Digest::digest_file('CHAES', @_) }
sub chaes_file_hex { Crypt::Digest::digest_file_hex('CHAES', @_) }
sub chaes_file_b64 { Crypt::Digest::digest_file_b64('CHAES', @_) }
sub chaes_file_b64u { Crypt::Digest::digest_file_b64u('CHAES', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::CHAES - Hash function - CipherHash based on AES [size: 128 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::CHAES qw( chaes chaes_hex chaes_b64 chaes_b64u
chaes_file chaes_file_hex chaes_file_b64 chaes_file_b64u );
# calculate digest from string/buffer
$chaes_raw = chaes('data string');
$chaes_hex = chaes_hex('data string');
$chaes_b64 = chaes_b64('data string');
$chaes_b64u = chaes_b64u('data string');
# calculate digest from file
$chaes_raw = chaes_file('filename.dat');
$chaes_hex = chaes_file_hex('filename.dat');
$chaes_b64 = chaes_file_b64('filename.dat');
$chaes_b64u = chaes_file_b64u('filename.dat');
# calculate digest from filehandle
$chaes_raw = chaes_file(*FILEHANDLE);
$chaes_hex = chaes_file_hex(*FILEHANDLE);
$chaes_b64 = chaes_file_b64(*FILEHANDLE);
$chaes_b64u = chaes_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::CHAES;
$d = Crypt::Digest::CHAES->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the CHAES digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::CHAES qw(chaes chaes_hex chaes_b64 chaes_b64u
chaes_file chaes_file_hex chaes_file_b64 chaes_file_b64u);
Or all of them at once:
use Crypt::Digest::CHAES ':all';
=head1 FUNCTIONS
=head2 chaes
Logically joins all arguments into a single string, and returns its CHAES digest encoded as a binary string.
$chaes_raw = chaes('data string');
#or
$chaes_raw = chaes('any data', 'more data', 'even more data');
=head2 chaes_hex
Logically joins all arguments into a single string, and returns its CHAES digest encoded as a hexadecimal string.
$chaes_hex = chaes_hex('data string');
#or
$chaes_hex = chaes_hex('any data', 'more data', 'even more data');
=head2 chaes_b64
Logically joins all arguments into a single string, and returns its CHAES digest encoded as a Base64 string, B<with> trailing '=' padding.
$chaes_b64 = chaes_b64('data string');
#or
$chaes_b64 = chaes_b64('any data', 'more data', 'even more data');
=head2 chaes_b64u
Logically joins all arguments into a single string, and returns its CHAES digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$chaes_b64url = chaes_b64u('data string');
#or
$chaes_b64url = chaes_b64u('any data', 'more data', 'even more data');
=head2 chaes_file
Reads file (defined by filename or filehandle) content, and returns its CHAES digest encoded as a binary string.
$chaes_raw = chaes_file('filename.dat');
#or
$chaes_raw = chaes_file(*FILEHANDLE);
=head2 chaes_file_hex
Reads file (defined by filename or filehandle) content, and returns its CHAES digest encoded as a hexadecimal string.
$chaes_hex = chaes_file_hex('filename.dat');
#or
$chaes_hex = chaes_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 chaes_file_b64
Reads file (defined by filename or filehandle) content, and returns its CHAES digest encoded as a Base64 string, B<with> trailing '=' padding.
$chaes_b64 = chaes_file_b64('filename.dat');
#or
$chaes_b64 = chaes_file_b64(*FILEHANDLE);
=head2 chaes_file_b64u
Reads file (defined by filename or filehandle) content, and returns its CHAES digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$chaes_b64url = chaes_file_b64u('filename.dat');
#or
$chaes_b64url = chaes_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::CHAES->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::CHAES->hashsize();
#or
Crypt::Digest::CHAES::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/Cryptographic_hash_function#Hash_functions_based_on_block_ciphers>
=back
=cut

View File

@ -1,223 +0,0 @@
package Crypt::Digest::Keccak224;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( keccak224 keccak224_hex keccak224_b64 keccak224_b64u keccak224_file keccak224_file_hex keccak224_file_b64 keccak224_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('Keccak224') }
sub keccak224 { Crypt::Digest::digest_data('Keccak224', @_) }
sub keccak224_hex { Crypt::Digest::digest_data_hex('Keccak224', @_) }
sub keccak224_b64 { Crypt::Digest::digest_data_b64('Keccak224', @_) }
sub keccak224_b64u { Crypt::Digest::digest_data_b64u('Keccak224', @_) }
sub keccak224_file { Crypt::Digest::digest_file('Keccak224', @_) }
sub keccak224_file_hex { Crypt::Digest::digest_file_hex('Keccak224', @_) }
sub keccak224_file_b64 { Crypt::Digest::digest_file_b64('Keccak224', @_) }
sub keccak224_file_b64u { Crypt::Digest::digest_file_b64u('Keccak224', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::Keccak224 - Hash function Keccak-224 [size: 224 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::Keccak224 qw( keccak224 keccak224_hex keccak224_b64 keccak224_b64u
keccak224_file keccak224_file_hex keccak224_file_b64 keccak224_file_b64u );
# calculate digest from string/buffer
$keccak224_raw = keccak224('data string');
$keccak224_hex = keccak224_hex('data string');
$keccak224_b64 = keccak224_b64('data string');
$keccak224_b64u = keccak224_b64u('data string');
# calculate digest from file
$keccak224_raw = keccak224_file('filename.dat');
$keccak224_hex = keccak224_file_hex('filename.dat');
$keccak224_b64 = keccak224_file_b64('filename.dat');
$keccak224_b64u = keccak224_file_b64u('filename.dat');
# calculate digest from filehandle
$keccak224_raw = keccak224_file(*FILEHANDLE);
$keccak224_hex = keccak224_file_hex(*FILEHANDLE);
$keccak224_b64 = keccak224_file_b64(*FILEHANDLE);
$keccak224_b64u = keccak224_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::Keccak224;
$d = Crypt::Digest::Keccak224->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the Keccak224 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::Keccak224 qw(keccak224 keccak224_hex keccak224_b64 keccak224_b64u
keccak224_file keccak224_file_hex keccak224_file_b64 keccak224_file_b64u);
Or all of them at once:
use Crypt::Digest::Keccak224 ':all';
=head1 FUNCTIONS
=head2 keccak224
Logically joins all arguments into a single string, and returns its Keccak224 digest encoded as a binary string.
$keccak224_raw = keccak224('data string');
#or
$keccak224_raw = keccak224('any data', 'more data', 'even more data');
=head2 keccak224_hex
Logically joins all arguments into a single string, and returns its Keccak224 digest encoded as a hexadecimal string.
$keccak224_hex = keccak224_hex('data string');
#or
$keccak224_hex = keccak224_hex('any data', 'more data', 'even more data');
=head2 keccak224_b64
Logically joins all arguments into a single string, and returns its Keccak224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak224_b64 = keccak224_b64('data string');
#or
$keccak224_b64 = keccak224_b64('any data', 'more data', 'even more data');
=head2 keccak224_b64u
Logically joins all arguments into a single string, and returns its Keccak224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak224_b64url = keccak224_b64u('data string');
#or
$keccak224_b64url = keccak224_b64u('any data', 'more data', 'even more data');
=head2 keccak224_file
Reads file (defined by filename or filehandle) content, and returns its Keccak224 digest encoded as a binary string.
$keccak224_raw = keccak224_file('filename.dat');
#or
$keccak224_raw = keccak224_file(*FILEHANDLE);
=head2 keccak224_file_hex
Reads file (defined by filename or filehandle) content, and returns its Keccak224 digest encoded as a hexadecimal string.
$keccak224_hex = keccak224_file_hex('filename.dat');
#or
$keccak224_hex = keccak224_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 keccak224_file_b64
Reads file (defined by filename or filehandle) content, and returns its Keccak224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak224_b64 = keccak224_file_b64('filename.dat');
#or
$keccak224_b64 = keccak224_file_b64(*FILEHANDLE);
=head2 keccak224_file_b64u
Reads file (defined by filename or filehandle) content, and returns its Keccak224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak224_b64url = keccak224_file_b64u('filename.dat');
#or
$keccak224_b64url = keccak224_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::Keccak224->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::Keccak224->hashsize();
#or
Crypt::Digest::Keccak224::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://keccak.team/index.html>
=back
=cut

View File

@ -1,223 +0,0 @@
package Crypt::Digest::Keccak256;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.058_002';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( keccak256 keccak256_hex keccak256_b64 keccak256_b64u keccak256_file keccak256_file_hex keccak256_file_b64 keccak256_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('Keccak256') }
sub keccak256 { Crypt::Digest::digest_data('Keccak256', @_) }
sub keccak256_hex { Crypt::Digest::digest_data_hex('Keccak256', @_) }
sub keccak256_b64 { Crypt::Digest::digest_data_b64('Keccak256', @_) }
sub keccak256_b64u { Crypt::Digest::digest_data_b64u('Keccak256', @_) }
sub keccak256_file { Crypt::Digest::digest_file('Keccak256', @_) }
sub keccak256_file_hex { Crypt::Digest::digest_file_hex('Keccak256', @_) }
sub keccak256_file_b64 { Crypt::Digest::digest_file_b64('Keccak256', @_) }
sub keccak256_file_b64u { Crypt::Digest::digest_file_b64u('Keccak256', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::Keccak256 - Hash function Keccak-256 [size: 256 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::Keccak256 qw( keccak256 keccak256_hex keccak256_b64 keccak256_b64u
keccak256_file keccak256_file_hex keccak256_file_b64 keccak256_file_b64u );
# calculate digest from string/buffer
$keccak256_raw = keccak256('data string');
$keccak256_hex = keccak256_hex('data string');
$keccak256_b64 = keccak256_b64('data string');
$keccak256_b64u = keccak256_b64u('data string');
# calculate digest from file
$keccak256_raw = keccak256_file('filename.dat');
$keccak256_hex = keccak256_file_hex('filename.dat');
$keccak256_b64 = keccak256_file_b64('filename.dat');
$keccak256_b64u = keccak256_file_b64u('filename.dat');
# calculate digest from filehandle
$keccak256_raw = keccak256_file(*FILEHANDLE);
$keccak256_hex = keccak256_file_hex(*FILEHANDLE);
$keccak256_b64 = keccak256_file_b64(*FILEHANDLE);
$keccak256_b64u = keccak256_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::Keccak256;
$d = Crypt::Digest::Keccak256->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the Keccak256 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::Keccak256 qw(keccak256 keccak256_hex keccak256_b64 keccak256_b64u
keccak256_file keccak256_file_hex keccak256_file_b64 keccak256_file_b64u);
Or all of them at once:
use Crypt::Digest::Keccak256 ':all';
=head1 FUNCTIONS
=head2 keccak256
Logically joins all arguments into a single string, and returns its Keccak256 digest encoded as a binary string.
$keccak256_raw = keccak256('data string');
#or
$keccak256_raw = keccak256('any data', 'more data', 'even more data');
=head2 keccak256_hex
Logically joins all arguments into a single string, and returns its Keccak256 digest encoded as a hexadecimal string.
$keccak256_hex = keccak256_hex('data string');
#or
$keccak256_hex = keccak256_hex('any data', 'more data', 'even more data');
=head2 keccak256_b64
Logically joins all arguments into a single string, and returns its Keccak256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak256_b64 = keccak256_b64('data string');
#or
$keccak256_b64 = keccak256_b64('any data', 'more data', 'even more data');
=head2 keccak256_b64u
Logically joins all arguments into a single string, and returns its Keccak256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak256_b64url = keccak256_b64u('data string');
#or
$keccak256_b64url = keccak256_b64u('any data', 'more data', 'even more data');
=head2 keccak256_file
Reads file (defined by filename or filehandle) content, and returns its Keccak256 digest encoded as a binary string.
$keccak256_raw = keccak256_file('filename.dat');
#or
$keccak256_raw = keccak256_file(*FILEHANDLE);
=head2 keccak256_file_hex
Reads file (defined by filename or filehandle) content, and returns its Keccak256 digest encoded as a hexadecimal string.
$keccak256_hex = keccak256_file_hex('filename.dat');
#or
$keccak256_hex = keccak256_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 keccak256_file_b64
Reads file (defined by filename or filehandle) content, and returns its Keccak256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak256_b64 = keccak256_file_b64('filename.dat');
#or
$keccak256_b64 = keccak256_file_b64(*FILEHANDLE);
=head2 keccak256_file_b64u
Reads file (defined by filename or filehandle) content, and returns its Keccak256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak256_b64url = keccak256_file_b64u('filename.dat');
#or
$keccak256_b64url = keccak256_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::Keccak256->new();
=head2 clone
$d->clone();
=head2 reset
$d->reset();
=head2 add
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
=head2 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::Keccak256->hashsize();
#or
Crypt::Digest::Keccak256::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://keccak.team/index.html>
=back
=cut

Some files were not shown because too many files have changed in this diff Show More