diff options
-rw-r--r-- | tests/tlsfeature-ext.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/tlsfeature-ext.c b/tests/tlsfeature-ext.c index 9723c3d9ab..ebe476f3cc 100644 --- a/tests/tlsfeature-ext.c +++ b/tests/tlsfeature-ext.c @@ -30,12 +30,42 @@ #include <assert.h> #include "utils.h" +unsigned char der_feat_long[] = + "\x30\x82\x01\x80\x02\x01\x00\x02\x01\x01\x02\x01\x02\x02\x01\x03" + "\x02\x01\x04\x02\x01\x05\x02\x01\x06\x02\x01\x07\x02\x01\x08\x02" + "\x01\x09\x02\x01\x0A\x02\x01\x0B\x02\x01\x0C\x02\x01\x0D\x02\x01" + "\x0E\x02\x01\x0F\x02\x01\x10\x02\x01\x11\x02\x01\x12\x02\x01\x13" + "\x02\x01\x14\x02\x01\x15\x02\x01\x16\x02\x01\x17\x02\x01\x18\x02" + "\x01\x19\x02\x01\x1A\x02\x01\x1B\x02\x01\x1C\x02\x01\x1D\x02\x01" + "\x1E\x02\x01\x1F\x02\x01\x20\x02\x01\x21\x02\x01\x22\x02\x01\x23" + "\x02\x01\x24\x02\x01\x25\x02\x01\x26\x02\x01\x27\x02\x01\x28\x02" + "\x01\x29\x02\x01\x2A\x02\x01\x2B\x02\x01\x2C\x02\x01\x2D\x02\x01" + "\x2E\x02\x01\x2F\x02\x01\x30\x02\x01\x31\x02\x01\x32\x02\x01\x33" + "\x02\x01\x34\x02\x01\x35\x02\x01\x36\x02\x01\x37\x02\x01\x38\x02" + "\x01\x39\x02\x01\x3A\x02\x01\x3B\x02\x01\x3C\x02\x01\x3D\x02\x01" + "\x3E\x02\x01\x3F\x02\x01\x40\x02\x01\x41\x02\x01\x42\x02\x01\x43" + "\x02\x01\x44\x02\x01\x45\x02\x01\x46\x02\x01\x47\x02\x01\x48\x02" + "\x01\x49\x02\x01\x4A\x02\x01\x4B\x02\x01\x4C\x02\x01\x4D\x02\x01" + "\x4E\x02\x01\x4F\x02\x01\x50\x02\x01\x51\x02\x01\x52\x02\x01\x53" + "\x02\x01\x54\x02\x01\x55\x02\x01\x56\x02\x01\x57\x02\x01\x58\x02" + "\x01\x59\x02\x01\x5A\x02\x01\x5B\x02\x01\x5C\x02\x01\x5D\x02\x01" + "\x5E\x02\x01\x5F\x02\x01\x60\x02\x01\x61\x02\x01\x62\x02\x01\x63" + "\x02\x01\x64\x02\x01\x65\x02\x01\x66\x02\x01\x67\x02\x01\x68\x02" + "\x01\x69\x02\x01\x6A\x02\x01\x6B\x02\x01\x6C\x02\x01\x6D\x02\x01" + "\x6E\x02\x01\x6F\x02\x01\x70\x02\x01\x71\x02\x01\x72\x02\x01\x73" + "\x02\x01\x74\x02\x01\x75\x02\x01\x76\x02\x01\x77\x02\x01\x78\x02" + "\x01\x79\x02\x01\x7A\x02\x01\x7B\x02\x01\x7C\x02\x01\x7D\x02\x01" + "\x7E\x02\x01\x7F"; + +static gnutls_datum_t der_long = { der_feat_long, sizeof(der_feat_long)-1}; + void doit(void) { int ret; gnutls_x509_tlsfeatures_t feat; unsigned int out; gnutls_datum_t der; + unsigned i; ret = global_init(); if (ret < 0) @@ -93,8 +123,30 @@ void doit(void) assert(gnutls_x509_tlsfeatures_get(feat, 0, &out) == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE); gnutls_x509_tlsfeatures_deinit(feat); + gnutls_free(der.data); + /* check whether we can add a reasonable number of features */ + assert(gnutls_x509_tlsfeatures_init(&feat) >= 0); + + for (i=0;i<128;i++) { + ret = gnutls_x509_tlsfeatures_add(feat, i); + if (ret < 0) { + assert(i>=32); + assert(ret == GNUTLS_E_INTERNAL_ERROR); + } + } + + gnutls_x509_tlsfeatures_deinit(feat); + + /* check whether we can import a very long list */ + assert(gnutls_x509_tlsfeatures_init(&feat) >= 0); + + /* we don't fail, we simply import to our upper limit with no error */ + assert(gnutls_x509_ext_import_tlsfeatures(&der_long, feat, 0) == GNUTLS_E_INTERNAL_ERROR); + + gnutls_x509_tlsfeatures_deinit(feat); + gnutls_global_deinit(); } |