FreeBSD/sys/geom/eli/g_eli_key.c
/*
 * Encrypt the Master-Key and calculate HMAC to be able to verify it in the
 * future.
 */
Encrypt the Master-Key and calculate HMAC to be able to verify it in the
future.
Encrypt the Master - Key and calculate HMAC to be able to verify it in the future .
int
g_eli_mkey_encrypt(unsigned algo, const unsigned char *key, unsigned keylen,
    unsigned char *mkey)
{
	unsigned char enckey[SHA512_MDLEN];	
	int error;
	g_eli_mkey_hmac(mkey, key);
	g_eli_crypto_hmac(key, G_ELI_USERKEYLEN, "\x01", 1, enckey, 0);
	error = g_eli_crypto_encrypt(algo, mkey, G_ELI_MKEYLEN, enckey, keylen);
	bzero(enckey, sizeof(enckey));
	return (error);
}
int g_eli_mkey_encrypt ( unsigned algo , const unsigned char * key , unsigned keylen , unsigned char * mkey ) { unsigned char enckey [ SHA512_MDLEN ] ; int error ; g_eli_mkey_hmac ( mkey , key ) ; g_eli_crypto_hmac ( key , G_ELI_USERKEYLEN , " \x01 " , 1 , enckey , 0 ) ; error = g_eli_crypto_encrypt ( algo , mkey , G_ELI_MKEYLEN , enckey , keylen ) ; bzero ( enckey , sizeof ( enckey ) ) ; return ( error ) ; }
Encrypt the Master-Key and calculate HMAC to be able to verify it in the
 future.
Encrypt the Master - Key and calculate HMAC to be able to verify it in the future .
/* Key for encryption. */ /*
	 * To calculate HMAC, the whole key (G_ELI_USERKEYLEN bytes long) will
	 * be used.
	 */ /*
	 * The key for encryption is: enckey = HMAC_SHA512(Derived-Key, 1)
	 */ /*
	 * Encrypt the Master-Key and HMAC() result with the given key (this
	 * time only 'keylen' bits from the key are used).
	 */