krb5_error_code KRB5_CALLCONV krb5_string_to_deltat(char *, krb5_deltat *);
krb5_error_code KRB5_CALLCONV krb5_enctype_to_string(krb5_enctype, char *,
size_t);
+krb5_error_code KRB5_CALLCONV krb5_enctype_to_name(krb5_enctype, krb5_boolean,
+ char *, size_t);
krb5_error_code KRB5_CALLCONV krb5_salttype_to_string(krb5_int32, char *,
size_t);
krb5_error_code KRB5_CALLCONV krb5_cksumtype_to_string(krb5_cksumtype, char *,
*enctypep = ktp->etype;
return 0;
}
-#define MAX_ALIASES (sizeof(ktp->aliases) / sizeof(ktp->aliases[0]))
- for (j = 0; j < MAX_ALIASES; j++) {
+ for (j = 0; j < MAX_ETYPE_ALIASES; j++) {
alias = ktp->aliases[j];
if (alias == NULL)
break;
return ENOMEM;
return 0;
}
+
+krb5_error_code KRB5_CALLCONV
+krb5_enctype_to_name(krb5_enctype enctype, krb5_boolean shortest,
+ char *buffer, size_t buflen)
+{
+ const struct krb5_keytypes *ktp;
+ const char *name;
+ int i;
+
+ ktp = find_enctype(enctype);
+ if (ktp == NULL)
+ return EINVAL;
+ name = ktp->name;
+ if (shortest) {
+ for (i = 0; i < MAX_ETYPE_ALIASES; i++) {
+ if (ktp->aliases[i] == NULL)
+ break;
+ if (strlen(ktp->aliases[i]) < strlen(name))
+ name = ktp->aliases[i];
+ }
+ }
+ if (strlcpy(buffer, name, buflen) >= buflen)
+ return ENOMEM;
+ return 0;
+}
#include "k5-int.h"
+#define MAX_ETYPE_ALIASES 2
+
struct krb5_keytypes;
typedef unsigned int (*crypto_length_func)(const struct krb5_keytypes *ktp,
struct krb5_keytypes {
krb5_enctype etype;
char *name;
- char *aliases[2];
+ char *aliases[MAX_ETYPE_ALIASES];
char *out_string;
const struct krb5_enc_provider *enc;
const struct krb5_hash_provider *hash;