@@ -503,6 +503,25 @@ ossl_ts_req_to_der(VALUE self)
503
503
return asn1_to_der ((void * )req , (int (* )(void * , unsigned char * * ))i2d_TS_REQ );
504
504
}
505
505
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
+
506
525
static VALUE
507
526
ossl_ts_resp_alloc (VALUE klass )
508
527
{
@@ -757,6 +776,25 @@ ossl_ts_resp_to_der(VALUE self)
757
776
return asn1_to_der ((void * )resp , (int (* )(void * , unsigned char * * ))i2d_TS_RESP );
758
777
}
759
778
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
+
760
798
/*
761
799
* Verifies a timestamp token by checking the signature, validating the
762
800
* certificate chain implied by tsa_certificate and by checking conformance to
@@ -1073,6 +1111,25 @@ ossl_ts_token_info_to_der(VALUE self)
1073
1111
return asn1_to_der ((void * )info , (int (* )(void * , unsigned char * * ))i2d_TS_TST_INFO );
1074
1112
}
1075
1113
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
+
1076
1133
static ASN1_INTEGER *
1077
1134
ossl_tsfac_serial_cb (struct TS_resp_ctx * ctx , void * data )
1078
1135
{
@@ -1356,6 +1413,7 @@ Init_ossl_ts(void)
1356
1413
rb_define_method (cTimestampResponse , "token_info" , ossl_ts_resp_get_token_info , 0 );
1357
1414
rb_define_method (cTimestampResponse , "tsa_certificate" , ossl_ts_resp_get_tsa_certificate , 0 );
1358
1415
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 );
1359
1417
rb_define_method (cTimestampResponse , "verify" , ossl_ts_resp_verify , -1 );
1360
1418
1361
1419
/* Document-class: OpenSSL::Timestamp::TokenInfo
@@ -1374,6 +1432,7 @@ Init_ossl_ts(void)
1374
1432
rb_define_method (cTimestampTokenInfo , "ordering" , ossl_ts_token_info_get_ordering , 0 );
1375
1433
rb_define_method (cTimestampTokenInfo , "nonce" , ossl_ts_token_info_get_nonce , 0 );
1376
1434
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 );
1377
1436
1378
1437
/* Document-class: OpenSSL::Timestamp::Request
1379
1438
* Allows to create timestamp requests or parse existing ones. A Request is
@@ -1399,6 +1458,7 @@ Init_ossl_ts(void)
1399
1458
rb_define_method (cTimestampRequest , "cert_requested=" , ossl_ts_req_set_cert_requested , 1 );
1400
1459
rb_define_method (cTimestampRequest , "cert_requested?" , ossl_ts_req_get_cert_requested , 0 );
1401
1460
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 );
1402
1462
1403
1463
/*
1404
1464
* Indicates a successful response. Equal to +0+.
0 commit comments