Use centralized hasher names in pki utility
This commit is contained in:
@@ -105,8 +105,8 @@ static int issue()
|
||||
}
|
||||
continue;
|
||||
case 'g':
|
||||
digest = get_digest(arg);
|
||||
if (digest == HASH_UNKNOWN)
|
||||
digest = enum_from_name(hash_algorithm_short_names, arg);
|
||||
if (digest == -1)
|
||||
{
|
||||
error = "invalid --digest type";
|
||||
goto usage;
|
||||
|
||||
@@ -63,8 +63,8 @@ static int req()
|
||||
}
|
||||
continue;
|
||||
case 'g':
|
||||
digest = get_digest(arg);
|
||||
if (digest == HASH_UNKNOWN)
|
||||
digest = enum_from_name(hash_algorithm_short_names, arg);
|
||||
if (digest == -1)
|
||||
{
|
||||
error = "invalid --digest type";
|
||||
goto usage;
|
||||
|
||||
@@ -94,8 +94,8 @@ static int self()
|
||||
}
|
||||
continue;
|
||||
case 'g':
|
||||
digest = get_digest(arg);
|
||||
if (digest == HASH_UNKNOWN)
|
||||
digest = enum_from_name(hash_algorithm_short_names, arg);
|
||||
if (digest == -1)
|
||||
{
|
||||
error = "invalid --digest type";
|
||||
goto usage;
|
||||
|
||||
@@ -141,8 +141,8 @@ static int sign_crl()
|
||||
case 'h':
|
||||
goto usage;
|
||||
case 'g':
|
||||
digest = get_digest(arg);
|
||||
if (digest == HASH_UNKNOWN)
|
||||
digest = enum_from_name(hash_algorithm_short_names, arg);
|
||||
if (digest == -1)
|
||||
{
|
||||
error = "invalid --digest type";
|
||||
goto usage;
|
||||
|
||||
@@ -79,38 +79,6 @@ bool get_form(char *form, cred_encoding_type_t *enc, credential_type_t type)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a digest string to a hash algorithm
|
||||
*/
|
||||
hash_algorithm_t get_digest(char *name)
|
||||
{
|
||||
if (streq(name, "md5"))
|
||||
{
|
||||
return HASH_MD5;
|
||||
}
|
||||
if (streq(name, "sha1"))
|
||||
{
|
||||
return HASH_SHA1;
|
||||
}
|
||||
if (streq(name, "sha224"))
|
||||
{
|
||||
return HASH_SHA224;
|
||||
}
|
||||
if (streq(name, "sha256"))
|
||||
{
|
||||
return HASH_SHA256;
|
||||
}
|
||||
if (streq(name, "sha384"))
|
||||
{
|
||||
return HASH_SHA384;
|
||||
}
|
||||
if (streq(name, "sha512"))
|
||||
{
|
||||
return HASH_SHA512;
|
||||
}
|
||||
return HASH_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback credential set pki uses
|
||||
*/
|
||||
|
||||
@@ -31,9 +31,4 @@
|
||||
*/
|
||||
bool get_form(char *form, cred_encoding_type_t *enc, credential_type_t type);
|
||||
|
||||
/**
|
||||
* Convert a digest string to a hash algorithm
|
||||
*/
|
||||
hash_algorithm_t get_digest(char *name);
|
||||
|
||||
#endif /** PKI_H_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user