FreeBSD/sys/geom/eli/g_eli_key.c
/*
 * Verify if the given 'key' is correct.
 * Return 1 if it is correct and 0 otherwise.
 */
Verify if the given 'key' is correct.
Return 1 if it is correct and 0 otherwise.
Verify if the given ' key ' is correct . Return 1 if it is correct and 0 otherwise .
static int
g_eli_mkey_verify(const unsigned char *mkey, const unsigned char *key)
{
	const unsigned char *odhmac;	
	unsigned char chmac[SHA512_MDLEN];	
	unsigned char hmkey[SHA512_MDLEN];	
	g_eli_crypto_hmac(key, G_ELI_USERKEYLEN, "\x00", 1, hmkey, 0);
	odhmac = mkey + G_ELI_DATAIVKEYLEN;
	g_eli_crypto_hmac(hmkey, sizeof(hmkey), mkey, G_ELI_DATAIVKEYLEN,
	    chmac, 0);
	bzero(hmkey, sizeof(hmkey));
	return (!bcmp(odhmac, chmac, SHA512_MDLEN));
}
static int g_eli_mkey_verify ( const unsigned char * mkey , const unsigned char * key ) { const unsigned char * odhmac ; unsigned char chmac [ SHA512_MDLEN ] ; unsigned char hmkey [ SHA512_MDLEN ] ; g_eli_crypto_hmac ( key , G_ELI_USERKEYLEN , " \x00 " , 1 , hmkey , 0 ) ; odhmac = mkey + G_ELI_DATAIVKEYLEN ; g_eli_crypto_hmac ( hmkey , sizeof ( hmkey ) , mkey , G_ELI_DATAIVKEYLEN , chmac , 0 ) ; bzero ( hmkey , sizeof ( hmkey ) ) ; return ( ! bcmp ( odhmac , chmac , SHA512_MDLEN ) ) ; }
Verify if the given 'key' is correct.
Verify if the given ' key ' is correct .
/* On-disk HMAC. */ /* Calculated HMAC. */ /* Key for HMAC. */ /*
	 * The key for HMAC calculations is: hmkey = HMAC_SHA512(Derived-Key, 0)
	 */ /* Calculate HMAC from Data-Key and IV-Key. */ /*
	 * Compare calculated HMAC with HMAC from metadata.
	 * If two HMACs are equal, 'key' is correct.
	 */