// PureNoise CryptoLib (c) 1997-2004, PureNoise Ltd Vaduz #ifndef _crypto_big_h_ #define _crypto_big_h_ #include #include //! This function compresses or expands the supplied big number using multiple Tiger hashes to the necessary length, that is CIPHER_KEY_WORDS (8) and then initializes the key stream using aes_setkey. The supplied key should be a regular big (a list of 32-bit words with the first element set to the total number of following words). It is recommended however that the key is at least CIPHER_KEY_BITS (256) bit long. key[0] containing the size of key in 32-bit words has to be a multiple of 16 (128-bit). //! \brief Initializes AES encryption/decryption key stream from a "big" key //! \param key a big with the elements key[1] to key[key[0]] in LSF byte order; see make_LSF from //! \param cipher type of the cipher to be used for encryption (0 for Twofish, 1 for RC6, 2 for Serpent, 3 for Rijndael, otherwise Chaos only) //! \retval ks the keystream to use for aes_encrypt, aes_decrypt, big_encrypt, big_decrypt, base64_encrypt, base64_decrypt //! \returns pointer to ks EXTERN aes_keystream * big_setkey (const unsigned long *key, const unsigned long keysize, const unsigned long cipher, aes_keystream *ks); //! Once cryptblock is encrypted with big_encrypt, it cannot be decrypted in parts as all the bits within the block become inter-dependant. That inter-dependency makes it easy to verify the validity of encryption. Simply include an ID in the block. Its presence in the right place can ensure correct decryption of the entire block. //! \brief encrypts a large block of data in the form of a "big" with AES encryption chaining all its small blocks to each other //! \pre cryptblock[0] representing the size of the block in 32-bit words has to be a multiple of CIPHER_BLOCK_WORDS (4) //! \pre cryptblock[1]..cryptblock[cryptblock[0]] elements have to be converted to LSF byte order prior to encryption; see make_LSF in //! \post cryptblock does not change in size //! \param cryptblock the "big" block to be encrypted //! \param ks the keystream to use to encrypt the big //! \retval cryptblock encrypted //! \returns pointer to cryptblock EXTERN unsigned long * big_encrypt (unsigned long *cryptblock, const unsigned long blocksize, const aes_keystream *ks); //! Once cryptblock is encrypted with big_encrypt, it cannot be decrypted in parts as all the bits within the block become inter-dependant. That inter-dependency makes it easy to verify the validity of encryption. Simply include an ID in the block. Its presence in the right place can ensure correct decryption of the entire block. //! \brief decrypts a large block of data encrypted with big_encrypt AES encryption unchaining all its small blocks from each other //! \pre cryptblock[0] representing the size of the block in 32-bit words has to be a multiple of CIPHER_BLOCK_WORDS (4) //! \pre cryptblock[1]..cryptblock[cryptblock[0]] elements have to be converted from LSF byte order after decryption; see make_LSF in //! \post cryptblock does not change in size; convert data back from LSF byte order //! \param cryptblock the "big" block to be encrypted //! \param ks the keystream to use to decrypt the big encrypted previously with big_encrypt //! \retval cryptblock decrypted //! \returns pointer to cryptblock EXTERN unsigned long * big_decrypt (unsigned long *cryptblock, const unsigned long blocksize, const aes_keystream *ks); EXTERN unsigned long * chaos_hash (unsigned long *target, const unsigned long to_words, const unsigned long *source, const unsigned long from_words); #endif // _crypto_big_h_