ASN1_STRING_length(3) OpenSSL ASN1_STRING_length(3) NNAAMMEE ASN1_STRING_dup, ASN1_STRING_cmp, ASN1_STRING_set, ASN1_STRING_length, ASN1_STRING_length_set, ASN1_STRING_type, ASN1_STRING_data - ASN1_STRING utility functions SSYYNNOOPPSSIISS #include int ASN1_STRING_length(ASN1_STRING *x); unsigned char * ASN1_STRING_data(ASN1_STRING *x); ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b); int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); int ASN1_STRING_type(ASN1_STRING *x); int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); DDEESSCCRRIIPPTTIIOONN These functions allow an AASSNN11__SSTTRRIINNGG structure to be manipulated. _A_S_N_1___S_T_R_I_N_G___l_e_n_g_t_h_(_) returns the length of the content of xx. _A_S_N_1___S_T_R_I_N_G___d_a_t_a_(_) returns an internal pointer to the data of xx. Since this is an internal pointer it should nnoott be freed or modified in any way. _A_S_N_1___S_T_R_I_N_G___d_u_p_(_) returns a copy of the structure aa. _A_S_N_1___S_T_R_I_N_G___c_m_p_(_) compares aa and bb returning 0 if the two are identi- cal. The string types and content are compared. _A_S_N_1___S_T_R_I_N_G___s_e_t_(_) sets the data of string ssttrr to the buffer ddaattaa or length lleenn. The supplied data is copied. If lleenn is -1 then the length is determined by strlen(data). _A_S_N_1___S_T_R_I_N_G___t_y_p_e_(_) returns the type of xx, using standard constants such as VV__AASSNN11__OOCCTTEETT__SSTTRRIINNGG. _A_S_N_1___S_T_R_I_N_G___t_o___U_T_F_8_(_) converts the string iinn to UTF8 format, the con- verted data is allocated in a buffer in **oouutt. The length of oouutt is returned or a negative error code. The buffer **oouutt should be free using _O_P_E_N_S_S_L___f_r_e_e_(_). NNOOTTEESS Almost all ASN1 types in OpenSSL are represented as an AASSNN11__SSTTRRIINNGG structure. Other types such as AASSNN11__OOCCTTEETT__SSTTRRIINNGG are simply typedefed to AASSNN11__SSTTRRIINNGG and the functions call the AASSNN11__SSTTRRIINNGG equivalents. AASSNN11__SSTTRRIINNGG is also used for some CCHHOOIICCEE types which consist entirely of primitive string types such as DDiirreeccttoorryySSttrriinngg and TTiimmee. These functions should nnoott be used to examine or modify AASSNN11__IINNTTEEGGEERR or AASSNN11__EENNUUMMEERRAATTEEDD types: the relevant IINNTTEEGGEERR or EENNUUMMEERRAATTEEDD utility func- tions should be used instead. In general it cannot be assumed that the data returned by _A_S_N_1___S_T_R_I_N_G___d_a_t_a_(_) is null terminated or does not contain embedded nulls. The actual format of the data will depend on the actual string type itself: for example for and IA5String the data will be ASCII, for a BMPString two bytes per character in big endian format, UTF8String will be in UTF8 format. Similar care should be take to ensure the data is in the correct format when calling _A_S_N_1___S_T_R_I_N_G___s_e_t_(_). RREETTUURRNN VVAALLUUEESS SSEEEE AALLSSOO _E_R_R___g_e_t___e_r_r_o_r(3) HHIISSTTOORRYY 1.0.1u 2016-09-22 ASN1_STRING_length(3)