@@ -503,6 +503,25 @@ ossl_ts_req_to_der(VALUE self)
503503 return asn1_to_der ((void * )req , (int (* )(void * , unsigned char * * ))i2d_TS_REQ );
504504}
505505
506+ static VALUE
507+ ossl_ts_req_to_text (VALUE self )
508+ {
509+ TS_REQ * req ;
510+ BIO * out ;
511+
512+ GetTSRequest (self , req );
513+
514+ out = BIO_new (BIO_s_mem ());
515+ if (!out ) ossl_raise (eTimestampError , NULL );
516+
517+ if (!TS_REQ_print_bio (out , req )) {
518+ BIO_free (out );
519+ ossl_raise (eTimestampError , NULL );
520+ }
521+
522+ return ossl_membio2str (out );
523+ }
524+
506525static VALUE
507526ossl_ts_resp_alloc (VALUE klass )
508527{
@@ -757,6 +776,25 @@ ossl_ts_resp_to_der(VALUE self)
757776 return asn1_to_der ((void * )resp , (int (* )(void * , unsigned char * * ))i2d_TS_RESP );
758777}
759778
779+ static VALUE
780+ ossl_ts_resp_to_text (VALUE self )
781+ {
782+ TS_RESP * resp ;
783+ BIO * out ;
784+
785+ GetTSResponse (self , resp );
786+
787+ out = BIO_new (BIO_s_mem ());
788+ if (!out ) ossl_raise (eTimestampError , NULL );
789+
790+ if (!TS_RESP_print_bio (out , resp )) {
791+ BIO_free (out );
792+ ossl_raise (eTimestampError , NULL );
793+ }
794+
795+ return ossl_membio2str (out );
796+ }
797+
760798/*
761799 * Verifies a timestamp token by checking the signature, validating the
762800 * certificate chain implied by tsa_certificate and by checking conformance to
@@ -1073,6 +1111,25 @@ ossl_ts_token_info_to_der(VALUE self)
10731111 return asn1_to_der ((void * )info , (int (* )(void * , unsigned char * * ))i2d_TS_TST_INFO );
10741112}
10751113
1114+ static VALUE
1115+ ossl_ts_token_info_to_text (VALUE self )
1116+ {
1117+ TS_TST_INFO * info ;
1118+ BIO * out ;
1119+
1120+ GetTSTokenInfo (self , info );
1121+
1122+ out = BIO_new (BIO_s_mem ());
1123+ if (!out ) ossl_raise (eTimestampError , NULL );
1124+
1125+ if (!TS_TST_INFO_print_bio (out , info )) {
1126+ BIO_free (out );
1127+ ossl_raise (eTimestampError , NULL );
1128+ }
1129+
1130+ return ossl_membio2str (out );
1131+ }
1132+
10761133static ASN1_INTEGER *
10771134ossl_tsfac_serial_cb (struct TS_resp_ctx * ctx , void * data )
10781135{
@@ -1356,6 +1413,7 @@ Init_ossl_ts(void)
13561413 rb_define_method (cTimestampResponse , "token_info" , ossl_ts_resp_get_token_info , 0 );
13571414 rb_define_method (cTimestampResponse , "tsa_certificate" , ossl_ts_resp_get_tsa_certificate , 0 );
13581415 rb_define_method (cTimestampResponse , "to_der" , ossl_ts_resp_to_der , 0 );
1416+ rb_define_method (cTimestampResponse , "to_text" , ossl_ts_resp_to_text , 0 );
13591417 rb_define_method (cTimestampResponse , "verify" , ossl_ts_resp_verify , -1 );
13601418
13611419 /* Document-class: OpenSSL::Timestamp::TokenInfo
@@ -1374,6 +1432,7 @@ Init_ossl_ts(void)
13741432 rb_define_method (cTimestampTokenInfo , "ordering" , ossl_ts_token_info_get_ordering , 0 );
13751433 rb_define_method (cTimestampTokenInfo , "nonce" , ossl_ts_token_info_get_nonce , 0 );
13761434 rb_define_method (cTimestampTokenInfo , "to_der" , ossl_ts_token_info_to_der , 0 );
1435+ rb_define_method (cTimestampTokenInfo , "to_text" , ossl_ts_token_info_to_text , 0 );
13771436
13781437 /* Document-class: OpenSSL::Timestamp::Request
13791438 * Allows to create timestamp requests or parse existing ones. A Request is
@@ -1399,6 +1458,7 @@ Init_ossl_ts(void)
13991458 rb_define_method (cTimestampRequest , "cert_requested=" , ossl_ts_req_set_cert_requested , 1 );
14001459 rb_define_method (cTimestampRequest , "cert_requested?" , ossl_ts_req_get_cert_requested , 0 );
14011460 rb_define_method (cTimestampRequest , "to_der" , ossl_ts_req_to_der , 0 );
1461+ rb_define_method (cTimestampRequest , "to_text" , ossl_ts_req_to_text , 0 );
14021462
14031463 /*
14041464 * Indicates a successful response. Equal to +0+.
0 commit comments