From 250751135454656057d1a8d877e698a93c7002be Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 18 Jul 2013 13:45:05 +0000 Subject: -removing last bits of RSA support, as this code is now dead --- src/include/gnunet_common.h | 2 +- src/include/gnunet_crypto_lib.h | 362 ---------------------------------------- 2 files changed, 1 insertion(+), 363 deletions(-) (limited to 'src/include') diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 116971179..ab0876ef9 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -57,7 +57,7 @@ extern "C" /** * Version of the API (for entire gnunetutil.so library). */ -#define GNUNET_UTIL_VERSION 0x00090500 +#define GNUNET_UTIL_VERSION 0x00090501 /** * Named constants for return values. The following diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 5329d76cb..da2fe860e 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h @@ -71,23 +71,6 @@ enum GNUNET_CRYPTO_Quality */ #define GNUNET_CRYPTO_AES_KEY_LENGTH (256/8) -/** - * @brief Length of RSA encrypted data (2048 bit) - * - * We currently do not handle encryption of data - * that can not be done in a single call to the - * RSA methods (read: large chunks of data). - * We should never need that, as we can use - * the GNUNET_CRYPTO_hash for larger pieces of data for signing, - * and for encryption, we only need to encode sessionkeys! - */ -#define GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH 256 - -/** - * Length of an RSA KEY (n,e,len), 2048 bit (=256 octests) key n, 2 byte e - */ -#define GNUNET_CRYPTO_RSA_KEY_LENGTH 258 - /** * Length of a hash value */ @@ -105,44 +88,12 @@ enum GNUNET_CRYPTO_Quality #define GNUNET_CRYPTO_ECC_MAX_PUBLIC_KEY_LENGTH 76 -/** - * The private information of an RSA key pair. - */ -struct GNUNET_CRYPTO_RsaPrivateKey; - /** * The private information of an ECC private key. */ struct GNUNET_CRYPTO_EccPrivateKey; -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * GNUnet mandates a certain format for the encoding - * of private RSA key information that is provided - * by the RSA implementations. This format is used - * to serialize a private RSA key (typically when - * writing it to disk). - */ -struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded -{ - /** - * Total size of the structure, in bytes, in big-endian! - */ - uint16_t len GNUNET_PACKED; - uint16_t sizen GNUNET_PACKED; /* in big-endian! */ - uint16_t sizee GNUNET_PACKED; /* in big-endian! */ - uint16_t sized GNUNET_PACKED; /* in big-endian! */ - uint16_t sizep GNUNET_PACKED; /* in big-endian! */ - uint16_t sizeq GNUNET_PACKED; /* in big-endian! */ - uint16_t sizedmp1 GNUNET_PACKED; /* in big-endian! */ - uint16_t sizedmq1 GNUNET_PACKED; /* in big-endian! */ - /* followed by the actual values */ -}; -GNUNET_NETWORK_STRUCT_END - - /** * @brief 0-terminated ASCII encoding of a struct GNUNET_HashCode. */ @@ -162,77 +113,8 @@ struct GNUNET_CRYPTO_ShortHashAsciiEncoded -/** - * @brief an RSA signature - */ -struct GNUNET_CRYPTO_RsaSignature -{ - unsigned char sig[GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH]; -}; - - GNUNET_NETWORK_STRUCT_BEGIN -/** - * @brief header of what an RSA signature signs - * this must be followed by "size - 8" bytes of - * the actual signed data - */ -struct GNUNET_CRYPTO_RsaSignaturePurpose -{ - /** - * How many bytes does this signature sign? - * (including this purpose header); in network - * byte order (!). - */ - uint32_t size GNUNET_PACKED; - - /** - * What does this signature vouch for? This - * must contain a GNUNET_SIGNATURE_PURPOSE_XXX - * constant (from gnunet_signatures.h). In - * network byte order! - */ - uint32_t purpose GNUNET_PACKED; - -}; - - -/** - * @brief A public key. - */ -struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded -{ - /** - * In big-endian, must be GNUNET_CRYPTO_RSA_KEY_LENGTH+4 - */ - uint16_t len GNUNET_PACKED; - - /** - * Size of n in key; in big-endian! - */ - uint16_t sizen GNUNET_PACKED; - - /** - * The key itself, contains n followed by e. - */ - unsigned char key[GNUNET_CRYPTO_RSA_KEY_LENGTH]; - - /** - * Padding (must be 0) - */ - uint16_t padding GNUNET_PACKED; -}; - - -/** - * RSA Encrypted data. - */ -struct GNUNET_CRYPTO_RsaEncryptedData -{ - unsigned char encoding[GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH]; -}; - /** * @brief header of what an ECC signature signs @@ -931,250 +813,6 @@ GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len, ...); -/** - * Convert a public key to a string. - * - * @param pub key to convert - * @return string representing 'pub' - */ -char * -GNUNET_CRYPTO_rsa_public_key_to_string (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pub); - - -/** - * Convert a string representing a public key to a public key. - * - * @param enc encoded public key - * @param enclen number of bytes in enc (without 0-terminator) - * @param pub where to store the public key - * @return GNUNET_OK on success - */ -int -GNUNET_CRYPTO_rsa_public_key_from_string (const char *enc, - size_t enclen, - struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pub); - - -/** - * Encode the private key in a format suitable for - * storing it into a file. - * @return encoding of the private key - */ -struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * -GNUNET_CRYPTO_rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey); - - -/** - * Decode the private key from the data-format back - * to the "normal", internal format. - * - * @param buf the buffer where the private key data is stored - * @param len the length of the data in 'buffer' - * @return NULL on error - */ -struct GNUNET_CRYPTO_RsaPrivateKey * -GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len); - - -/** - * Create a new private key by reading it from a file. If the - * files does not exist, create a new key and write it to the - * file. Caller must free return value. Note that this function - * can not guarantee that another process might not be trying - * the same operation on the same file at the same time. - * If the contents of the file - * are invalid the old file is deleted and a fresh key is - * created. - * - * @param filename name of file to use for storage - * @return new private key, NULL on error (for example, - * permission denied) - * @deprecated use 'GNUNET_CRYPTO_rsa_key_create_start' instead - */ -struct GNUNET_CRYPTO_RsaPrivateKey * -GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename); - - -/** - * Open existing private key file and read it. If the - * file does not exist, or the contents of the file are - * invalid, the function fails - * Caller must free returned value. - * - * @return a private key, NULL on error (for example, - * permission denied) or when file does not exist or contains invalid - * data. - */ -struct GNUNET_CRYPTO_RsaPrivateKey * -GNUNET_CRYPTO_rsa_key_create_from_existing_file (const char *filename); - - -/** - * Handle to cancel private key generation. - */ -struct GNUNET_CRYPTO_RsaKeyGenerationContext; - - -/** - * Function called upon completion of 'GNUNET_CRYPTO_rsa_key_create_async'. - * - * @param cls closure - * @param pk NULL on error, otherwise the private key (which must be free'd by the callee) - * @param emsg NULL on success, otherwise an error message - */ -typedef void (*GNUNET_CRYPTO_RsaKeyCallback)(void *cls, - struct GNUNET_CRYPTO_RsaPrivateKey *pk, - const char *emsg); - - -/** - * Create a new private key by reading it from a file. If the files - * does not exist, create a new key and write it to the file. If the - * contents of the file are invalid the old file is deleted and a - * fresh key is created. - * - * @param filename name of file to use for storage - * @param cont function to call when done (or on errors) - * @param cont_cls closure for 'cont' - * @return handle to abort operation, NULL on fatal errors (cont will not be called if NULL is returned) - */ -struct GNUNET_CRYPTO_RsaKeyGenerationContext * -GNUNET_CRYPTO_rsa_key_create_start (const char *filename, - GNUNET_CRYPTO_RsaKeyCallback cont, - void *cont_cls); - - -/** - * Abort RSA key generation. - * - * @param gc key generation context to abort - */ -void -GNUNET_CRYPTO_rsa_key_create_stop (struct GNUNET_CRYPTO_RsaKeyGenerationContext *gc); - - -/** - * Setup a hostkey file for a peer given the name of the - * configuration file (!). This function is used so that - * at a later point code can be certain that reading a - * hostkey is fast (for example in time-dependent testcases). - * - * @param cfg_name name of the configuration file to use - */ -void -GNUNET_CRYPTO_rsa_setup_hostkey (const char *cfg_name); - - -/** - * Deterministically (!) create a private key using only the - * given HashCode as input to the PRNG. - * - * @param hc "random" input to PRNG - * @return some private key purely dependent on input - */ -struct GNUNET_CRYPTO_RsaPrivateKey * -GNUNET_CRYPTO_rsa_key_create_from_hash (const struct GNUNET_HashCode *hc); - - -/** - * Free memory occupied by the private key. - * - * @param key pointer to the memory to free - */ -void -GNUNET_CRYPTO_rsa_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key); - - -/** - * Extract the public key of the host. - * - * @param priv the private key - * @param pub where to write the public key - */ -void -GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey - *priv, - struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded - *pub); - - -/** - * Get hash of the public key that corresponds to a private key. - * - * @param key RSA private key - * @param id buffer for hash of the public key - */ -void -GNUNET_CRYPTO_rsa_get_public_key_hash (struct GNUNET_CRYPTO_RsaPrivateKey *key, - struct GNUNET_HashCode *id); - - -/** - * Encrypt a block with the public key of another host that uses the - * same cyper. - * - * @param block the block to encrypt - * @param size the size of block - * @param publicKey the encoded public key used to encrypt - * @param target where to store the encrypted block - * @return GNUNET_SYSERR on error, GNUNET_OK if ok - */ -int -GNUNET_CRYPTO_rsa_encrypt (const void *block, size_t size, - const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded - *publicKey, - struct GNUNET_CRYPTO_RsaEncryptedData *target); - - -/** - * Decrypt a given block with the hostkey. - * - * @param key the key to use - * @param block the data to decrypt, encoded as returned by encrypt, not consumed - * @param result pointer to a location where the result can be stored - * @param max how many bytes of a result are expected? Must be exact. - * @return the size of the decrypted block (that is, size) or -1 on error - */ -ssize_t -GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *key, - const struct GNUNET_CRYPTO_RsaEncryptedData *block, - void *result, size_t max); - - -/** - * Sign a given block. - * - * @param key private key to use for the signing - * @param purpose what to sign (size, purpose) - * @param sig where to write the signature - * @return GNUNET_SYSERR on error, GNUNET_OK on success - */ -int -GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *key, - const struct GNUNET_CRYPTO_RsaSignaturePurpose *purpose, - struct GNUNET_CRYPTO_RsaSignature *sig); - - -/** - * Verify signature. Note that the caller MUST have already - * checked that "validate->size" bytes are actually available. - * - * @param purpose what is the purpose that validate should have? - * @param validate block to validate (size, purpose, data) - * @param sig signature that is being validated - * @param publicKey public key of the signer - * @return GNUNET_OK if ok, GNUNET_SYSERR if invalid - */ -int -GNUNET_CRYPTO_rsa_verify (uint32_t purpose, - const struct GNUNET_CRYPTO_RsaSignaturePurpose - *validate, - const struct GNUNET_CRYPTO_RsaSignature *sig, - const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded - *publicKey); - - - /** * Function called upon completion of 'GNUNET_CRYPTO_ecc_key_create_async'. * -- cgit v1.2.3