mirror of
https://github.com/openssl/openssl.git
synced 2024-11-27 05:21:51 +08:00
crypto/pkcs12: default to UTF-8.
Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
70bf33d182
commit
b799aef863
@ -45,6 +45,16 @@ int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name,
|
||||
int namelen)
|
||||
{
|
||||
if (X509at_add1_attr_by_NID(&bag->attrib, NID_friendlyName,
|
||||
MBSTRING_UTF8, (unsigned char *)name, namelen))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,
|
||||
const unsigned char *name, int namelen)
|
||||
{
|
||||
@ -82,8 +92,8 @@ char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag)
|
||||
return NULL;
|
||||
if (atype->type != V_ASN1_BMPSTRING)
|
||||
return NULL;
|
||||
return OPENSSL_uni2asc(atype->value.bmpstring->data,
|
||||
atype->value.bmpstring->length);
|
||||
return OPENSSL_uni2utf8(atype->value.bmpstring->data,
|
||||
atype->value.bmpstring->length);
|
||||
}
|
||||
|
||||
const STACK_OF(X509_ATTRIBUTE) *
|
||||
|
@ -40,8 +40,8 @@ extern "C" {
|
||||
# define PKCS12_key_gen PKCS12_key_gen_uni
|
||||
# define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni
|
||||
# else
|
||||
# define PKCS12_key_gen PKCS12_key_gen_asc
|
||||
# define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc
|
||||
# define PKCS12_key_gen PKCS12_key_gen_utf8
|
||||
# define PKCS12_add_friendlyname PKCS12_add_friendlyname_utf8
|
||||
# endif
|
||||
|
||||
/* MS key usage constants */
|
||||
@ -141,6 +141,8 @@ int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,
|
||||
int namelen);
|
||||
int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,
|
||||
int namelen);
|
||||
int PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name,
|
||||
int namelen);
|
||||
int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,
|
||||
int namelen);
|
||||
int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,
|
||||
|
Loading…
Reference in New Issue
Block a user