D2I_TS_REQ(3)
π D2I_TS_REQ β decode & encode X.509 time-stamp protocol structures, bestie
okay so this is one of those man pages from the Library Functions Manual shelf (iykyk, the OpenBSD-flavoured one), and it's literally a whole family of functions whose entire job is turning time-stamp-protocol structures into DER bytes and back. twenty-eight functions. one page. we're doing this. π
β¨ NAME β¨
bestie, the whole girliepop squad is here β every one of these decodes and encodes X.509 time-stamp protocol structures:
- decoders (
d2i_, DER β struct):d2i_TS_REQ,d2i_TS_REQ_bio,d2i_TS_REQ_fp,d2i_TS_RESP,d2i_TS_RESP_bio,d2i_TS_RESP_fp,d2i_TS_STATUS_INFO,d2i_TS_TST_INFO,d2i_TS_TST_INFO_bio,d2i_TS_TST_INFO_fp,d2i_TS_ACCURACY,d2i_TS_MSG_IMPRINT,d2i_TS_MSG_IMPRINT_bio,d2i_TS_MSG_IMPRINT_fp - encoders (
i2d_, struct β DER):i2d_TS_REQ,i2d_TS_REQ_bio,i2d_TS_REQ_fp,i2d_TS_RESP,i2d_TS_RESP_bio,i2d_TS_RESP_fp,i2d_TS_STATUS_INFO,i2d_TS_TST_INFO,i2d_TS_TST_INFO_bio,i2d_TS_TST_INFO_fp,i2d_TS_ACCURACY,i2d_TS_MSG_IMPRINT,i2d_TS_MSG_IMPRINT_bio,i2d_TS_MSG_IMPRINT_fp
πΈ SYNOPSIS πΈ
this is libcrypto energy, and you're gonna want #include <openssl/ts.h>:
TS_REQ *
d2i_TS_REQ(TS_REQ **val_out, const unsigned char **der_in, long length);
int
i2d_TS_REQ(const TS_REQ *val_in, unsigned char **der_out);
TS_REQ *
d2i_TS_REQ_bio(BIO *in_bio, TS_REQ **val_out);
int
i2d_TS_REQ_bio(BIO *out_bio, TS_REQ *val_in);
TS_REQ *
d2i_TS_REQ_fp(FILE *in_fp, TS_REQ **val_out);
int
i2d_TS_REQ_fp(FILE *out_fp, TS_REQ *val_in);
TS_RESP *
d2i_TS_RESP(TS_RESP **val_out, const unsigned char **der_in,
long length);
int
i2d_TS_RESP(const TS_RESP *val_in, unsigned char **der_out);
TS_RESP *
d2i_TS_RESP_bio(BIO *in_bio, TS_RESP **val_out);
int
i2d_TS_RESP_bio(BIO *out_bio, TS_RESP *val_in);
TS_RESP *
d2i_TS_RESP_fp(FILE *in_fp, TS_RESP **val_out);
int
i2d_TS_RESP_fp(FILE *out_fp, TS_RESP *val_in);
TS_STATUS_INFO *
d2i_TS_STATUS_INFO(TS_STATUS_INFO **val_out,
const unsigned char **der_in, long length);
int
i2d_TS_STATUS_INFO(const TS_STATUS_INFO *val_in,
unsigned char **der_out);
TS_TST_INFO *
d2i_TS_TST_INFO(TS_TST_INFO **val_out, const unsigned char **der_in,
long length);
int
i2d_TS_TST_INFO(const TS_TST_INFO *val_in, unsigned char **der_out);
TS_TST_INFO *
d2i_TS_TST_INFO_bio(BIO *in_bio, TS_TST_INFO **val_out);
int
i2d_TS_TST_INFO_bio(BIO *out_bio, TS_TST_INFO *val_in);
TS_TST_INFO *
d2i_TS_TST_INFO_fp(FILE *in_fp, TS_TST_INFO **val_out);
int
i2d_TS_TST_INFO_fp(FILE *out_fp, TS_TST_INFO *val_in);
TS_ACCURACY *
d2i_TS_ACCURACY(TS_ACCURACY **val_out, const unsigned char **der_in,
long length);
int
i2d_TS_ACCURACY(const TS_ACCURACY *val_in, unsigned char **der_out);
TS_MSG_IMPRINT *
d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **val_out,
const unsigned char **der_in, long length);
int
i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *val_in,
unsigned char **der_out);
TS_MSG_IMPRINT *
d2i_TS_MSG_IMPRINT_bio(BIO *in_bio, TS_MSG_IMPRINT **val_out);
int
i2d_TS_MSG_IMPRINT_bio(BIO *out_bio, TS_MSG_IMPRINT *val_in);
TS_MSG_IMPRINT *
d2i_TS_MSG_IMPRINT_fp(FILE *in_fp, TS_MSG_IMPRINT **val_out);
int
i2d_TS_MSG_IMPRINT_fp(FILE *out_fp, TS_MSG_IMPRINT *val_in);
π¦ DESCRIPTION π¦
so these functions decode and encode the X.509 structures that the time-stamp protocol uses. and here's the thing β for the actual semantics, examples, caveats, and bugs, the page is like "go read ASN1_item_d2i(3)", so genuinely go do that, bestie, this page is not the main character for that part. π«Ά
π TS_REQ
d2i_TS_REQ() and i2d_TS_REQ() decode and encode an ASN.1 TimeStampReq structure defined in RFC 3161 section 2.4.1. and then d2i_TS_REQ_bio(), i2d_TS_REQ_bio(), d2i_TS_REQ_fp(), and i2d_TS_REQ_fp() are literally the same except they decode or encode using a BIO or FILE pointer. same vibe, different input/output plumbing. β¨
π TS_RESP
d2i_TS_RESP() and i2d_TS_RESP() decode and encode an ASN.1 TimeStampResp structure defined in RFC 3161 section 2.4.2. and d2i_TS_RESP_bio(), i2d_TS_RESP_bio(), d2i_TS_RESP_fp(), and i2d_TS_RESP_fp()? you guessed it β similar except they decode or encode using a BIO or FILE pointer. π
π TS_STATUS_INFO
d2i_TS_STATUS_INFO() and i2d_TS_STATUS_INFO() decode and encode an ASN.1 PKIStatusInfo structure defined in RFC 3161 section 2.4.2. no bio/fp variant here, she's a one-trick icon. π
π TS_TST_INFO
d2i_TS_TST_INFO() and i2d_TS_TST_INFO() decode and encode an ASN.1 TSTInfo structure defined in RFC 3161 section 2.4.2. and d2i_TS_TST_INFO_bio(), i2d_TS_TST_INFO_bio(), d2i_TS_TST_INFO_fp(), and i2d_TS_TST_INFO_fp() are similar except they decode or encode using a BIO or FILE pointer. π¦
π TS_ACCURACY
d2i_TS_ACCURACY() and i2d_TS_ACCURACY() decode and encode an ASN.1 Accuracy structure defined in RFC 3161 section 2.4.2. short and sweet, no notes. πΈ
π TS_MSG_IMPRINT
d2i_TS_MSG_IMPRINT() and i2d_TS_MSG_IMPRINT() decode and encode an ASN.1 MessageImprint structure defined in RFC 3161 section 2.4.1. and d2i_TS_MSG_IMPRINT_bio(), i2d_TS_MSG_IMPRINT_bio(), d2i_TS_MSG_IMPRINT_fp(), and i2d_TS_MSG_IMPRINT_fp() are similar except they decode or encode using a BIO or FILE pointer. β¨
π₯ RETURN VALUES π₯
okay this is the part where you actually pay attention, bestie, because there are three different return conventions and mixing them up is not the slay you think it is. π
the decoders β d2i_TS_REQ(), d2i_TS_REQ_bio(), d2i_TS_REQ_fp(), d2i_TS_RESP(), d2i_TS_RESP_bio(), d2i_TS_RESP_fp(), d2i_TS_STATUS_INFO(), d2i_TS_TST_INFO(), d2i_TS_TST_INFO_bio(), d2i_TS_TST_INFO_fp(), d2i_TS_ACCURACY(), d2i_TS_MSG_IMPRINT(), d2i_TS_MSG_IMPRINT_bio(), and d2i_TS_MSG_IMPRINT_fp() β return an object of the respective type, or NULL if an error occurs. π
the pointer-output encoders β i2d_TS_REQ(), i2d_TS_RESP(), i2d_TS_STATUS_INFO(), i2d_TS_TST_INFO(), i2d_TS_ACCURACY(), and i2d_TS_MSG_IMPRINT() β return the number of bytes successfully encoded, or a negative value if an error occurs. π₯
the bio/fp encoders β i2d_TS_REQ_bio(), i2d_TS_REQ_fp(), i2d_TS_RESP_bio(), i2d_TS_RESP_fp(), i2d_TS_TST_INFO_bio(), i2d_TS_TST_INFO_fp(), i2d_TS_MSG_IMPRINT_bio(), and i2d_TS_MSG_IMPRINT_fp() β return 1 for success or 0 if an error occurs. π
real talk: three return styles, one man page. check which one you're calling, or you're gonna have a bad time. π
π SEE ALSO π
ASN1_item_d2i(3)β the actual lore drop, go read itTS_REQ_new(3)
β STANDARDS β
RFC 3161: Internet X.509 Public Key Infrastructure Time-Stamp Protocol. that's the whole standard, she ate. π
π HISTORY π
these functions first appeared in OpenSSL 1.0.0 and have been available since OpenBSD 4.9. vintage but still iconic, fr fr. π§
mwah, that's the page! π this one's from the Debian build, dated June 8, 2025, and it lives at D2I_TS_REQ(3) in section 3 of the manual. go forth and encode responsibly, bestie π«Άβ¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms