example/ipsec_crypto/odp_ipsec_misc.h
static inline
int parse_key_string(char *keystring,
		     ipsec_key_t *key,
		     ipsec_alg_t *alg)
{
	int idx;
	int key_bits_in = KEY_STR_BITS(keystring);
	char temp[3];

	key->length = 0;

	/* Algorithm is either cipher or authentication */
	if (alg->cipher) {
		if ((alg->u.cipher == ODP_CIPHER_ALG_3DES_CBC) &&
		    (KEY_BITS_3DES == key_bits_in))
			key->length = key_bits_in / 8;

	} else {
		if ((alg->u.auth == ODP_AUTH_ALG_MD5_HMAC) &&
		    (KEY_BITS_MD5_96 == key_bits_in))
			key->length = key_bits_in / 8;
		else if ((alg->u.auth == ODP_AUTH_ALG_SHA1_HMAC) &&
			 (KEY_BITS_SHA1_96 == key_bits_in))
			key->length = key_bits_in / 8;
		else if ((alg->u.auth == ODP_AUTH_ALG_SHA256_HMAC) &&
			 (KEY_BITS_SHA256_128 == key_bits_in))
			key->length = key_bits_in / 8;
	}

	for (idx = 0; idx < key->length; idx++) {
		temp[0] = *keystring++;
		temp[1] = *keystring++;
		temp[2] = 0;
		key->data[idx] = strtol(temp, NULL, 16);
	}

	return key->length ? 0 : -1;
}
/**
 * Parse text string representing a key into ODP key structure
 *
 * @param keystring  Pointer to key string to convert
 * @param key        Pointer to ODP key structure to populate
 * @param alg        Cipher/authentication algorithm associated with the key
 *
 * @return 0 if successful else -1
 */
Parse text string representing a key into ODP key structure
@param keystring  Pointer to key string to convert
@param key        Pointer to ODP key structure to populate
@param alg        Cipher/authentication algorithm associated with the key

@return 0 if successful else -1
Parse text string representing a key into ODP key structure @param keystring Pointer to key string to convert @param key Pointer to ODP key structure to populate @param alg Cipher / authentication algorithm associated with the key @return 0 if successful else - 1
static inline
int parse_key_string(char *keystring,
		     ipsec_key_t *key,
		     ipsec_alg_t *alg)
{
	int idx;
	int key_bits_in = KEY_STR_BITS(keystring);
	char temp[3];
	key->length = 0;
	if (alg->cipher) {
		if ((alg->u.cipher == ODP_CIPHER_ALG_3DES_CBC) &&
		    (KEY_BITS_3DES == key_bits_in))
			key->length = key_bits_in / 8;
	} else {
		if ((alg->u.auth == ODP_AUTH_ALG_MD5_HMAC) &&
		    (KEY_BITS_MD5_96 == key_bits_in))
			key->length = key_bits_in / 8;
		else if ((alg->u.auth == ODP_AUTH_ALG_SHA1_HMAC) &&
			 (KEY_BITS_SHA1_96 == key_bits_in))
			key->length = key_bits_in / 8;
		else if ((alg->u.auth == ODP_AUTH_ALG_SHA256_HMAC) &&
			 (KEY_BITS_SHA256_128 == key_bits_in))
			key->length = key_bits_in / 8;
	}
	for (idx = 0; idx < key->length; idx++) {
		temp[0] = *keystring++;
		temp[1] = *keystring++;
		temp[2] = 0;
		key->data[idx] = strtol(temp, NULL, 16);
	}
	return key->length ? 0 : -1;
}
static inline int parse_key_string ( char * keystring , ipsec_key_t * key , ipsec_alg_t * alg ) { int idx ; int key_bits_in = KEY_STR_BITS ( keystring ) ; char temp [ 3 ] ; key -> length = 0 ; if ( alg -> cipher ) { if ( ( alg -> u . cipher == ODP_CIPHER_ALG_3DES_CBC ) && ( KEY_BITS_3DES == key_bits_in ) ) key -> length = key_bits_in / 8 ; } else { if ( ( alg -> u . auth == ODP_AUTH_ALG_MD5_HMAC ) && ( KEY_BITS_MD5_96 == key_bits_in ) ) key -> length = key_bits_in / 8 ; else if ( ( alg -> u . auth == ODP_AUTH_ALG_SHA1_HMAC ) && ( KEY_BITS_SHA1_96 == key_bits_in ) ) key -> length = key_bits_in / 8 ; else if ( ( alg -> u . auth == ODP_AUTH_ALG_SHA256_HMAC ) && ( KEY_BITS_SHA256_128 == key_bits_in ) ) key -> length = key_bits_in / 8 ; } for ( idx = 0 ; idx < key -> length ; idx ++ ) { temp [ 0 ] = * keystring ++ ; temp [ 1 ] = * keystring ++ ; temp [ 2 ] = 0 ; key -> data [ idx ] = strtol ( temp , NULL , 16 ) ; } return key -> length ? 0 : -1 ; }
Parse text string representing a key into ODP key structure
 @param keystring  Pointer to key string to convert
 @param key        Pointer to ODP key structure to populate
 @param alg        Cipher/authentication algorithm associated with the key
Parse text string representing a key into ODP key structure @param keystring Pointer to key string to convert @param key Pointer to ODP key structure to populate @param alg Cipher / authentication algorithm associated with the key
/* Algorithm is either cipher or authentication */