summaryrefslogtreecommitdiff
path: root/lib/x509/x509_ext.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/x509/x509_ext.c')
-rw-r--r--lib/x509/x509_ext.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/x509/x509_ext.c b/lib/x509/x509_ext.c
index ce1ce9b30c..b68ac75edd 100644
--- a/lib/x509/x509_ext.c
+++ b/lib/x509/x509_ext.c
@@ -1116,7 +1116,9 @@ int gnutls_x509_ext_export_key_usage(unsigned int usage, gnutls_datum_t * ext)
str[0] = usage & 0xff;
str[1] = usage >> 8;
- result = asn1_write_value(c2, "", str, 2);
+ /* Since KeyUsage is a BIT STRING, the input to asn1_write_value
+ * is the number of bits to be read. */
+ result = asn1_write_value(c2, "", str, 9);
if (result != ASN1_SUCCESS) {
gnutls_assert();
asn1_delete_structure(&c2);