1 /* LTC_PKCS Header Info */ 2 module tomcrypt.pkcs; 3 4 import core.stdc.config : c_ulong; 5 6 import tomcrypt.prng; 7 8 extern(C) nothrow: 9 10 /* ===> LTC_PKCS #1 -- RSA Cryptography <=== */ 11 version(LTC_PKCS_1) 12 { 13 14 enum ltc_pkcs_1_v1_5_blocks 15 { 16 LTC_LTC_PKCS_1_EMSA = 1, /* Block type 1 (LTC_PKCS #1 v1.5 signature padding) */ 17 LTC_LTC_PKCS_1_EME = 2 /* Block type 2 (LTC_PKCS #1 v1.5 encryption padding) */ 18 } 19 enum LTC_LTC_PKCS_1_EMSA = ltc_pkcs_1_v1_5_blocks.LTC_LTC_PKCS_1_EMSA; 20 enum LTC_LTC_PKCS_1_EME = ltc_pkcs_1_v1_5_blocks.LTC_LTC_PKCS_1_EME; 21 22 enum ltc_pkcs_1_paddings 23 { 24 LTC_LTC_PKCS_1_V1_5 = 1, /* LTC_PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */ 25 LTC_LTC_PKCS_1_OAEP = 2, /* LTC_PKCS #1 v2.0 encryption padding */ 26 LTC_LTC_PKCS_1_PSS = 3 /* LTC_PKCS #1 v2.1 signature padding */ 27 } 28 enum LTC_LTC_PKCS_1_V1_5 = ltc_pkcs_1_paddings.LTC_LTC_PKCS_1_V1_5; 29 enum LTC_LTC_PKCS_1_OAEP = ltc_pkcs_1_paddings.LTC_LTC_PKCS_1_OAEP; 30 enum LTC_LTC_PKCS_1_PSS = ltc_pkcs_1_paddings.LTC_LTC_PKCS_1_PSS; 31 32 int pkcs_1_mgf1( int hash_idx, 33 const ubyte* seed, c_ulong seedlen, 34 ubyte* mask, c_ulong masklen); 35 36 int pkcs_1_i2osp(void *n, c_ulong modulus_len, ubyte* _out); 37 int pkcs_1_os2ip(void *n, ubyte* _in, c_ulong inlen); 38 39 /* *** v1.5 padding */ 40 int pkcs_1_v1_5_encode(const ubyte* msg, 41 c_ulong msglen, 42 int block_type, 43 c_ulong modulus_bitlen, 44 prng_state* prng, 45 int prng_idx, 46 ubyte* _out, 47 c_ulong* outlen); 48 49 int pkcs_1_v1_5_decode(const ubyte* msg, 50 c_ulong msglen, 51 int block_type, 52 c_ulong modulus_bitlen, 53 ubyte* _out, 54 c_ulong* outlen, 55 int* is_valid); 56 57 /* *** v2.1 padding */ 58 int pkcs_1_oaep_encode(const ubyte* msg, c_ulong msglen, 59 const ubyte* lparam, c_ulong lparamlen, 60 c_ulong modulus_bitlen, prng_state* prng, 61 int prng_idx, int hash_idx, 62 ubyte* _out, c_ulong* outlen); 63 64 int pkcs_1_oaep_decode(const ubyte* msg, c_ulong msglen, 65 const ubyte* lparam, c_ulong lparamlen, 66 c_ulong modulus_bitlen, int hash_idx, 67 ubyte* _out, c_ulong* outlen, 68 int* res); 69 70 int pkcs_1_pss_encode(const ubyte* msghash, c_ulong msghashlen, 71 c_ulong saltlen, prng_state* prng, 72 int prng_idx, int hash_idx, 73 c_ulong modulus_bitlen, 74 ubyte* _out, c_ulong* outlen); 75 76 int pkcs_1_pss_decode(const ubyte* msghash, c_ulong msghashlen, 77 const ubyte* sig, c_ulong siglen, 78 c_ulong saltlen, int hash_idx, 79 c_ulong modulus_bitlen, int* res); 80 81 } /* LTC_PKCS_1 */ 82 83 /* ===> LTC_PKCS #5 -- Password Based Cryptography <=== */ 84 version(LTC_PKCS_5) 85 { 86 87 /* Algorithm #1 (old) */ 88 int pkcs_5_alg1(const ubyte* password, c_ulong password_len, 89 const ubyte* salt, 90 int iteration_count, int hash_idx, 91 ubyte* _out, c_ulong* outlen); 92 93 /* Algorithm #2 (new) */ 94 int pkcs_5_alg2(const ubyte* password, c_ulong password_len, 95 const ubyte* salt, c_ulong salt_len, 96 int iteration_count, int hash_idx, 97 ubyte* _out, c_ulong* outlen); 98 99 } /* LTC_PKCS_5 */ 100 101 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_pkcs.h,v $ */ 102 /* $Revision: 1.8 $ */ 103 /* $Date: 2007/05/12 14:32:35 $ */