Commit 3c0940c4 authored by YueHaibing's avatar YueHaibing Committed by David Howells

crypto: pkcs7: Use match_string() helper to simplify the code

match_string() returns the array index of a matching string.
Use it instead of the open-coded implementation.
Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarBen Boeckel <mathstuf@gmail.com>
parent d13fc874
...@@ -141,11 +141,10 @@ int pkcs7_get_digest(struct pkcs7_message *pkcs7, const u8 **buf, u32 *len, ...@@ -141,11 +141,10 @@ int pkcs7_get_digest(struct pkcs7_message *pkcs7, const u8 **buf, u32 *len,
*buf = sinfo->sig->digest; *buf = sinfo->sig->digest;
*len = sinfo->sig->digest_size; *len = sinfo->sig->digest_size;
for (i = 0; i < HASH_ALGO__LAST; i++) i = match_string(hash_algo_name, HASH_ALGO__LAST,
if (!strcmp(hash_algo_name[i], sinfo->sig->hash_algo)) { sinfo->sig->hash_algo);
*hash_algo = i; if (i >= 0)
break; *hash_algo = i;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment