Loading doc/man3/ASN1_STRING_TABLE_add.pod +65 Changes for doc/man3/ASN1_STRING_TABLE_add.pod: 65 added lines, 0 removed lines. Original line number Diff line number Diff line =pod =head1 NAME ASN1_STRING_TABLE, ASN1_STRING_TABLE_add, ASN1_STRING_TABLE_get, ASN1_STRING_TABLE_cleanup - ASN1_STRING_TABLE manipulation functions =head1 SYNOPSIS #include <openssl/asn1.h> typedef struct asn1_string_table_st ASN1_STRING_TABLE; int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize, unsigned long mask, unsigned long flags); ASN1_STRING_TABLE * ASN1_STRING_TABLE_get(int nid); void ASN1_STRING_TABLE_cleanup(void); =head1 DESCRIPTION =head2 Types B<ASN1_STRING_TABLE> is a table which holds string information (basically minimum size, maximum size, type and etc) for a NID object. =head2 Functions ASN1_STRING_TABLE_add() adds a new B<ASN1_STRING_TABLE> item into the local ASN1 string table based on the B<nid> along with other parameters. If the item is already in the table, fields of B<ASN1_STRING_TABLE> are updated (depending on the values of those parameters, e.g., B<minsize> and B<maxsize> >= 0, B<mask> and B<flags> != 0). If the B<nid> is standard, a copy of the standard B<ASN1_STRING_TABLE> is created and updated with other parameters. ASN1_STRING_TABLE_get() searches for an B<ASN1_STRING_TABLE> item based on B<nid>. It will search the local table first, then the standard one. ASN1_STRING_TABLE_cleanup() frees all B<ASN1_STRING_TABLE> items added by ASN1_STRING_TABLE_add(). =head1 RETURN VALUES ASN1_STRING_TABLE_add() returns 1 on success, 0 if an error occurred. ASN1_STRING_TABLE_get() returns a valid B<ASN1_STRING_TABLE> structure or B<NULL> if nothing is found. ASN1_STRING_TABLE_cleanup() does not return a value. =head1 SEE ALSO L<ERR_get_error(3)> =head1 COPYRIGHT Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at L<https://www.openssl.org/source/license.html>. =cut test/asn1_string_table_test.c +76 Changes for test/asn1_string_table_test.c: 76 added lines, 0 removed lines. Original line number Diff line number Diff line /* * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ /* Tests for the ANS1_STRING_TABLE_* functions */ #include <stdio.h> #include <string.h> #include <openssl/asn1.h> #include "testutil.h" static int test_string_tbl() { const ASN1_STRING_TABLE *tmp = NULL; int nid = 12345678, nid2 = 87654321, rv = 0, ret = 0; tmp = ASN1_STRING_TABLE_get(nid); if (!TEST_ptr_null(tmp)) { TEST_info("asn1 string table: ASN1_STRING_TABLE_get non-exist nid"); goto out; } ret = ASN1_STRING_TABLE_add(nid, -1, -1, MBSTRING_ASC, 0); if (!TEST_true(ret)) { TEST_info("asn1 string table: add NID(%d) failed", nid); goto out; } ret = ASN1_STRING_TABLE_add(nid2, -1, -1, MBSTRING_ASC, 0); if (!TEST_true(ret)) { TEST_info("asn1 string table: add NID(%d) failed", nid2); goto out; } tmp = ASN1_STRING_TABLE_get(nid); if (!TEST_ptr(tmp)) { TEST_info("asn1 string table: get NID(%d) failed", nid); goto out; } tmp = ASN1_STRING_TABLE_get(nid2); if (!TEST_ptr(tmp)) { TEST_info("asn1 string table: get NID(%d) failed", nid2); goto out; } ASN1_STRING_TABLE_cleanup(); /* check if all newly added NIDs are cleaned up */ tmp = ASN1_STRING_TABLE_get(nid); if (!TEST_ptr_null(tmp)) { TEST_info("asn1 string table: get NID(%d) failed", nid); goto out; } tmp = ASN1_STRING_TABLE_get(nid2); if (!TEST_ptr_null(tmp)) { TEST_info("asn1 string table: get NID(%d) failed", nid2); goto out; } rv = 1; out: return rv; } void register_tests(void) { ADD_TEST(test_string_tbl); } test/build.info +5 −1 Changes for test/build.info: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN dtlsv1listentest ct_test threadstest afalgtest d2i_test \ ssl_test_ctx_test ssl_test x509aux cipherlist_test asynciotest \ bioprinttest sslapitest dtlstest sslcorrupttest bio_enc_test \ pkey_meth_test uitest cipherbytes_test asn1_encode_test \ pkey_meth_test uitest cipherbytes_test asn1_encode_test asn1_string_table_test \ x509_time_test x509_dup_cert_test x509_check_cert_pkey_test \ recordlentest drbgtest sslbuffertest \ time_offset_test pemtest ssl_cert_table_internal_test ciphername_test Loading Loading @@ -361,6 +361,10 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN INCLUDE[asn1_encode_test]=../include DEPEND[asn1_encode_test]=../libcrypto libtestutil.a SOURCE[asn1_string_table_test]=asn1_string_table_test.c INCLUDE[asn1_string_table_test]=../include DEPEND[asn1_string_table_test]=../libcrypto libtestutil.a SOURCE[time_offset_test]=time_offset_test.c INCLUDE[time_offset_test]=.. ../include DEPEND[time_offset_test]=../libcrypto libtestutil.a Loading test/recipes/04-test_asn1_string_table.t +12 Changes for test/recipes/04-test_asn1_string_table.t: 12 added lines, 0 removed lines. Original line number Diff line number Diff line #! /usr/bin/env perl # Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. # # Licensed under the OpenSSL license (the "License"). You may not use # this file except in compliance with the License. You can obtain a copy # in the file LICENSE in the source distribution or at # https://www.openssl.org/source/license.html use OpenSSL::Test::Simple; simple_test("test_asn1_string_table", "asn1_string_table_test"); util/private.num +1 Changes for util/private.num: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ OPENSSL_MALLOC_FAILURES environment OPENSSL_instrument_bus assembler OPENSSL_instrument_bus2 assembler # ASN1_STRING_TABLE datatype BIO_ADDR datatype BIO_ADDRINFO datatype BIO_callback_fn datatype Loading Loading
doc/man3/ASN1_STRING_TABLE_add.pod +65 Changes for doc/man3/ASN1_STRING_TABLE_add.pod: 65 added lines, 0 removed lines. Original line number Diff line number Diff line =pod =head1 NAME ASN1_STRING_TABLE, ASN1_STRING_TABLE_add, ASN1_STRING_TABLE_get, ASN1_STRING_TABLE_cleanup - ASN1_STRING_TABLE manipulation functions =head1 SYNOPSIS #include <openssl/asn1.h> typedef struct asn1_string_table_st ASN1_STRING_TABLE; int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize, unsigned long mask, unsigned long flags); ASN1_STRING_TABLE * ASN1_STRING_TABLE_get(int nid); void ASN1_STRING_TABLE_cleanup(void); =head1 DESCRIPTION =head2 Types B<ASN1_STRING_TABLE> is a table which holds string information (basically minimum size, maximum size, type and etc) for a NID object. =head2 Functions ASN1_STRING_TABLE_add() adds a new B<ASN1_STRING_TABLE> item into the local ASN1 string table based on the B<nid> along with other parameters. If the item is already in the table, fields of B<ASN1_STRING_TABLE> are updated (depending on the values of those parameters, e.g., B<minsize> and B<maxsize> >= 0, B<mask> and B<flags> != 0). If the B<nid> is standard, a copy of the standard B<ASN1_STRING_TABLE> is created and updated with other parameters. ASN1_STRING_TABLE_get() searches for an B<ASN1_STRING_TABLE> item based on B<nid>. It will search the local table first, then the standard one. ASN1_STRING_TABLE_cleanup() frees all B<ASN1_STRING_TABLE> items added by ASN1_STRING_TABLE_add(). =head1 RETURN VALUES ASN1_STRING_TABLE_add() returns 1 on success, 0 if an error occurred. ASN1_STRING_TABLE_get() returns a valid B<ASN1_STRING_TABLE> structure or B<NULL> if nothing is found. ASN1_STRING_TABLE_cleanup() does not return a value. =head1 SEE ALSO L<ERR_get_error(3)> =head1 COPYRIGHT Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at L<https://www.openssl.org/source/license.html>. =cut
test/asn1_string_table_test.c +76 Changes for test/asn1_string_table_test.c: 76 added lines, 0 removed lines. Original line number Diff line number Diff line /* * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ /* Tests for the ANS1_STRING_TABLE_* functions */ #include <stdio.h> #include <string.h> #include <openssl/asn1.h> #include "testutil.h" static int test_string_tbl() { const ASN1_STRING_TABLE *tmp = NULL; int nid = 12345678, nid2 = 87654321, rv = 0, ret = 0; tmp = ASN1_STRING_TABLE_get(nid); if (!TEST_ptr_null(tmp)) { TEST_info("asn1 string table: ASN1_STRING_TABLE_get non-exist nid"); goto out; } ret = ASN1_STRING_TABLE_add(nid, -1, -1, MBSTRING_ASC, 0); if (!TEST_true(ret)) { TEST_info("asn1 string table: add NID(%d) failed", nid); goto out; } ret = ASN1_STRING_TABLE_add(nid2, -1, -1, MBSTRING_ASC, 0); if (!TEST_true(ret)) { TEST_info("asn1 string table: add NID(%d) failed", nid2); goto out; } tmp = ASN1_STRING_TABLE_get(nid); if (!TEST_ptr(tmp)) { TEST_info("asn1 string table: get NID(%d) failed", nid); goto out; } tmp = ASN1_STRING_TABLE_get(nid2); if (!TEST_ptr(tmp)) { TEST_info("asn1 string table: get NID(%d) failed", nid2); goto out; } ASN1_STRING_TABLE_cleanup(); /* check if all newly added NIDs are cleaned up */ tmp = ASN1_STRING_TABLE_get(nid); if (!TEST_ptr_null(tmp)) { TEST_info("asn1 string table: get NID(%d) failed", nid); goto out; } tmp = ASN1_STRING_TABLE_get(nid2); if (!TEST_ptr_null(tmp)) { TEST_info("asn1 string table: get NID(%d) failed", nid2); goto out; } rv = 1; out: return rv; } void register_tests(void) { ADD_TEST(test_string_tbl); }
test/build.info +5 −1 Changes for test/build.info: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN dtlsv1listentest ct_test threadstest afalgtest d2i_test \ ssl_test_ctx_test ssl_test x509aux cipherlist_test asynciotest \ bioprinttest sslapitest dtlstest sslcorrupttest bio_enc_test \ pkey_meth_test uitest cipherbytes_test asn1_encode_test \ pkey_meth_test uitest cipherbytes_test asn1_encode_test asn1_string_table_test \ x509_time_test x509_dup_cert_test x509_check_cert_pkey_test \ recordlentest drbgtest sslbuffertest \ time_offset_test pemtest ssl_cert_table_internal_test ciphername_test Loading Loading @@ -361,6 +361,10 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN INCLUDE[asn1_encode_test]=../include DEPEND[asn1_encode_test]=../libcrypto libtestutil.a SOURCE[asn1_string_table_test]=asn1_string_table_test.c INCLUDE[asn1_string_table_test]=../include DEPEND[asn1_string_table_test]=../libcrypto libtestutil.a SOURCE[time_offset_test]=time_offset_test.c INCLUDE[time_offset_test]=.. ../include DEPEND[time_offset_test]=../libcrypto libtestutil.a Loading
test/recipes/04-test_asn1_string_table.t +12 Changes for test/recipes/04-test_asn1_string_table.t: 12 added lines, 0 removed lines. Original line number Diff line number Diff line #! /usr/bin/env perl # Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. # # Licensed under the OpenSSL license (the "License"). You may not use # this file except in compliance with the License. You can obtain a copy # in the file LICENSE in the source distribution or at # https://www.openssl.org/source/license.html use OpenSSL::Test::Simple; simple_test("test_asn1_string_table", "asn1_string_table_test");
util/private.num +1 Changes for util/private.num: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ OPENSSL_MALLOC_FAILURES environment OPENSSL_instrument_bus assembler OPENSSL_instrument_bus2 assembler # ASN1_STRING_TABLE datatype BIO_ADDR datatype BIO_ADDRINFO datatype BIO_callback_fn datatype Loading