krb5 commit: Add ASN.1 encoder/decoder for UTF-8 strings
Greg Hudson
ghudson at mit.edu
Wed Jul 22 13:29:32 EDT 2015
https://github.com/krb5/krb5/commit/d0f63158c3b0e9ebfe76c56136a575b41ec12642
commit d0f63158c3b0e9ebfe76c56136a575b41ec12642
Author: Greg Hudson <ghudson at mit.edu>
Date: Fri Dec 19 12:19:23 2014 -0500
Add ASN.1 encoder/decoder for UTF-8 strings
Add functions to encode and decode SEQUENCE OF UTF8String into a
null-terminated array of krb5_data pointers. This type is simple
enough that we don't need specific tests for it.
ticket: 8157
src/include/k5-int.h | 9 +++++++++
src/lib/krb5/asn.1/asn1_k_encode.c | 4 ++++
src/lib/krb5/krb/kfree.c | 10 ++++++++++
src/lib/krb5/libkrb5.exports | 3 +++
4 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/src/include/k5-int.h b/src/include/k5-int.h
index bde0842..e05524f 100644
--- a/src/include/k5-int.h
+++ b/src/include/k5-int.h
@@ -968,6 +968,9 @@ struct _krb5_authdata_context {
typedef struct _krb5_authdata_context *krb5_authdata_context;
+void
+k5_free_data_ptr_list(krb5_data **list);
+
void KRB5_CALLCONV
krb5int_free_data_list(krb5_context context, krb5_data *data);
@@ -1494,6 +1497,9 @@ encode_krb5_kkdcp_message(const krb5_kkdcp_message *, krb5_data **);
krb5_error_code
encode_krb5_cammac(const krb5_cammac *, krb5_data **);
+krb5_error_code
+encode_utf8_strings(krb5_data *const *ut8fstrings, krb5_data **);
+
/*************************************************************************
* End of prototypes for krb5_encode.c
*************************************************************************/
@@ -1670,6 +1676,9 @@ decode_krb5_kkdcp_message(const krb5_data *, krb5_kkdcp_message **);
krb5_error_code
decode_krb5_cammac(const krb5_data *, krb5_cammac **);
+krb5_error_code
+decode_utf8_strings(const krb5_data *, krb5_data ***);
+
struct _krb5_key_data; /* kdb.h */
struct ldap_seqof_key_data {
diff --git a/src/lib/krb5/asn.1/asn1_k_encode.c b/src/lib/krb5/asn.1/asn1_k_encode.c
index e173797..9e58389 100644
--- a/src/lib/krb5/asn.1/asn1_k_encode.c
+++ b/src/lib/krb5/asn.1/asn1_k_encode.c
@@ -92,6 +92,7 @@ DEFCOUNTEDSTRINGTYPE(utf8string, char *, unsigned int,
DEFCOUNTEDTYPE(utf8_data, krb5_data, data, length, utf8string);
DEFOPTIONALTYPE(opt_utf8_data, nonempty_data, NULL, utf8_data);
DEFPTRTYPE(utf8_data_ptr, utf8_data);
+DEFNULLTERMSEQOFTYPE(seqof_utf8_data, utf8_data_ptr);
DEFCOUNTEDSTRINGTYPE(object_identifier, char *, unsigned int,
k5_asn1_encode_bytestring, k5_asn1_decode_bytestring,
@@ -1793,3 +1794,6 @@ DEFSEQTYPE(cammac, krb5_cammac, cammac_fields);
MAKE_ENCODER(encode_krb5_cammac, cammac);
MAKE_DECODER(decode_krb5_cammac, cammac);
+
+MAKE_ENCODER(encode_utf8_strings, seqof_utf8_data);
+MAKE_DECODER(decode_utf8_strings, seqof_utf8_data);
diff --git a/src/lib/krb5/krb/kfree.c b/src/lib/krb5/krb/kfree.c
index 26200da..f3af260 100644
--- a/src/lib/krb5/krb/kfree.c
+++ b/src/lib/krb5/krb/kfree.c
@@ -692,6 +692,16 @@ krb5_free_fast_armored_req(krb5_context context, krb5_fast_armored_req *val)
free(val);
}
+void
+k5_free_data_ptr_list(krb5_data **list)
+{
+ int i;
+
+ for (i = 0; list != NULL && list[i] != NULL; i++)
+ krb5_free_data(NULL, list[i]);
+ free(list);
+}
+
void KRB5_CALLCONV
krb5int_free_data_list(krb5_context context, krb5_data *data)
{
diff --git a/src/lib/krb5/libkrb5.exports b/src/lib/krb5/libkrb5.exports
index e25158c..994ca34 100644
--- a/src/lib/krb5/libkrb5.exports
+++ b/src/lib/krb5/libkrb5.exports
@@ -47,6 +47,7 @@ decode_krb5_tgs_rep
decode_krb5_tgs_req
decode_krb5_ticket
decode_krb5_typed_data
+decode_utf8_strings
encode_krb5_ad_kdcissued
encode_krb5_ad_signedpath_data
encode_krb5_ad_signedpath
@@ -96,6 +97,7 @@ encode_krb5_tgs_rep
encode_krb5_tgs_req
encode_krb5_ticket
encode_krb5_typed_data
+encode_utf8_strings
et_asn1_error_table
et_k524_error_table
et_kdb5_error_table
@@ -117,6 +119,7 @@ k5_expand_path_tokens
k5_expand_path_tokens_extra
k5_free_algorithm_identifier
k5_free_cammac
+k5_free_data_ptr_list
k5_free_otp_tokeninfo
k5_free_kkdcp_message
k5_free_pa_otp_challenge
More information about the cvs-krb5
mailing list