/* Internal function. Register all the ciphers included in CIPHER_TABLE. Note, that this function gets only used by the macro REGISTER_DEFAULT_CIPHERS which protects it using a mutex. */ static void cipher_register_default (void) { gcry_err_code_t err = GPG_ERR_NO_ERROR; int i; for (i = 0; !err && cipher_table[i].cipher; i++) { if (! cipher_table[i].cipher->setkey) cipher_table[i].cipher->setkey = dummy_setkey; if (! cipher_table[i].cipher->encrypt) cipher_table[i].cipher->encrypt = dummy_encrypt_block; if (! cipher_table[i].cipher->decrypt) cipher_table[i].cipher->decrypt = dummy_decrypt_block; if (! cipher_table[i].cipher->stencrypt) cipher_table[i].cipher->stencrypt = dummy_encrypt_stream; if (! cipher_table[i].cipher->stdecrypt) cipher_table[i].cipher->stdecrypt = dummy_decrypt_stream; if ( fips_mode () && !cipher_table[i].fips_allowed ) continue; err = _gcry_module_add (&ciphers_registered, cipher_table[i].algorithm, (void *) cipher_table[i].cipher, (void *) cipher_table[i].extraspec, NULL); } if (err) BUG (); }
/* Register a new cipher module whose specification can be found in CIPHER. On success, a new algorithm ID is stored in ALGORITHM_ID and a pointer representhing this module is stored in MODULE. */ gcry_error_t _gcry_cipher_register (gcry_cipher_spec_t *cipher, cipher_extra_spec_t *extraspec, int *algorithm_id, gcry_module_t *module) { gcry_err_code_t err = 0; gcry_module_t mod; /* We do not support module loading in fips mode. */ if (fips_mode ()) return gpg_error (GPG_ERR_NOT_SUPPORTED); ath_mutex_lock (&ciphers_registered_lock); err = _gcry_module_add (&ciphers_registered, 0, (void *)cipher, (void *)(extraspec? extraspec : &dummy_extra_spec), &mod); ath_mutex_unlock (&ciphers_registered_lock); if (! err) { *module = mod; *algorithm_id = mod->mod_id; } return gcry_error (err); }
/* Register a new cipher module whose specification can be found in CIPHER. On success, a new algorithm ID is stored in ALGORITHM_ID and a pointer representhing this module is stored in MODULE. */ gcry_error_t gcry_cipher_register (gcry_cipher_spec_t *cipher, int *algorithm_id, gcry_module_t *module) { gcry_err_code_t err = 0; gcry_module_t mod; ath_mutex_lock (&ciphers_registered_lock); err = _gcry_module_add (&ciphers_registered, 0, (void *) cipher, &mod); ath_mutex_unlock (&ciphers_registered_lock); if (! err) { *module = mod; *algorithm_id = mod->mod_id; } return gcry_error (err); }