CryptX

 view release on metacpan or  search on metacpan

src/ltc/headers/tomcrypt_private.h  view on Meta::CPAN

                                     unsigned long  modulus_bitlen,
                                     unsigned char *out,           unsigned long *outlen);
int ltc_pkcs_1_pss_decode_mgf1(const unsigned char *msghash, unsigned long  msghashlen,
                               const unsigned char *sig,     unsigned long  siglen,
                               ltc_rsa_op_parameters *params,
                                     unsigned long  modulus_bitlen,    int *res);
int ltc_pkcs_1_oaep_encode(const unsigned char   *msg,    unsigned long msglen,
                          ltc_rsa_op_parameters *params,
                                unsigned long    modulus_bitlen,
                                unsigned char   *out,    unsigned long *outlen);
int ltc_pkcs_1_oaep_decode(const unsigned char *msg,    unsigned long msglen,
                         ltc_rsa_op_parameters *params,
                                 unsigned long  modulus_bitlen,
                                 unsigned char *out,    unsigned long *outlen,
                                 int           *res);

int ltc_pkcs_1_v1_5_encode(const unsigned char *msg,
                                 unsigned long  msglen,
                                           int  block_type,
                                 unsigned long  modulus_bitlen,
                                    prng_state *prng,
                                           int  prng_idx,
                                 unsigned char *out,
                                 unsigned long *outlen);
int ltc_pkcs_1_v1_5_decode(const unsigned char *msg,
                                 unsigned long  msglen,
                                           int  block_type,
                                 unsigned long  modulus_bitlen,
                                 unsigned char *out,
                                 unsigned long *outlen,
                                           int *is_valid);
#endif /* LTC_PKCS_1 */

#ifdef LTC_PKCS_8

/* Public-Key Cryptography Standards (PKCS) #8:
 * Private-Key Information Syntax Specification Version 1.2
 * https://tools.ietf.org/html/rfc5208
 *
 * PrivateKeyInfo ::= SEQUENCE {
 *      version                   Version,
 *      privateKeyAlgorithm       PrivateKeyAlgorithmIdentifier,
 *      privateKey                PrivateKey,
 *      attributes           [0]  IMPLICIT Attributes OPTIONAL }
 * where:
 * - Version ::= INTEGER
 * - PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
 * - PrivateKey ::= OCTET STRING
 * - Attributes ::= SET OF Attribute
 *
 * EncryptedPrivateKeyInfo ::= SEQUENCE {
 *        encryptionAlgorithm  EncryptionAlgorithmIdentifier,
 *        encryptedData        EncryptedData }
 * where:
 * - EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
 * - EncryptedData ::= OCTET STRING
 */

int pkcs8_decode_flexi(const unsigned char  *in,  unsigned long inlen,
                       const password_ctx   *pw_ctx,
                             ltc_asn1_list **decoded_list);

int pkcs8_get_children(const ltc_asn1_list *decoded_list, enum ltc_oid_id *pka,
                        ltc_asn1_list **alg_id, ltc_asn1_list **priv_key);

#endif  /* LTC_PKCS_8 */


#ifdef LTC_PKCS_12

int pkcs12_utf8_to_utf16(const unsigned char *in,  unsigned long  inlen,
                               unsigned char *out, unsigned long *outlen);

int pkcs12_kdf(               int   hash_id,
               const unsigned char *pw,         unsigned long pwlen,
               const unsigned char *salt,       unsigned long saltlen,
                     unsigned int   iterations, unsigned char purpose,
                     unsigned char *out,        unsigned long outlen);

#endif  /* LTC_PKCS_12 */

/* tomcrypt_prng.h */

#define LTC_PRNG_EXPORT(which) \
int which ## _export(unsigned char *out, unsigned long *outlen, prng_state *prng)      \
{                                                                                      \
   unsigned long len = which ## _desc.export_size;                                     \
                                                                                       \
   LTC_ARGCHK(prng   != NULL);                                                         \
   LTC_ARGCHK(out    != NULL);                                                         \
   LTC_ARGCHK(outlen != NULL);                                                         \
                                                                                       \
   if (*outlen < len) {                                                                \
      *outlen = len;                                                                   \
      return CRYPT_BUFFER_OVERFLOW;                                                    \
   }                                                                                   \
                                                                                       \
   if (which ## _read(out, len, prng) != len) {                                        \
      return CRYPT_ERROR_READPRNG;                                                     \
   }                                                                                   \
                                                                                       \
   *outlen = len;                                                                      \
   return CRYPT_OK;                                                                    \
}

/* extract a byte portably */
#ifdef _MSC_VER
   #define LTC_BYTE(x, n) ((unsigned char)((x) >> (8 * (n))))
#else
   #define LTC_BYTE(x, n) (((x) >> (8 * (n))) & 255)
#endif

/*
 * On Windows, choose whether to use CryptGenRandom() [older Windows versions]
 * or BCryptGenRandom() [newer Windows versions].
 * If CryptGenRandom() is desired, define LTC_NO_WIN32_BCRYPT when building.
 */
#if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
   #if !defined(LTC_NO_WIN32_BCRYPT)
      #define LTC_WIN32_BCRYPT
   #endif
#endif



( run in 0.538 second using v1.01-cache-2.11-cpan-39bf76dae61 )