Class: OpenSSL::Timestamp::TokenInfo
- Inherits:
-
Object
- Object
- OpenSSL::Timestamp::TokenInfo
- Defined in:
- ext/openssl/ossl_ts.c,
ext/openssl/ossl_ts.c
Overview
Immutable and read-only representation of a timestamp token info from a Response.
Instance Method Summary collapse
-
#algorithm ⇒ Object
Returns the ‘short name’ of the object identifier representing the algorithm that was used to derive the message imprint digest.
-
#gen_time ⇒ Object
Returns time when this timestamp token was created.
-
#initialize(der) ⇒ Object
constructor
Creates a TokenInfo from a
Fileorstringparameter, the correspondingFileorstringmust be DER-encoded. -
#message_imprint ⇒ Object
Returns the message imprint digest.
-
#nonce ⇒ Object
If the timestamp token is valid then this field contains the same nonce that was passed to the timestamp server in the initial Request.
-
#ordering ⇒ Object
If the ordering field is missing, or if the ordering field is present and set to false, then the genTime field only indicates the time at which the time-stamp token has been created by the TSA.
-
#policy_id ⇒ Object
Returns the timestamp policy object identifier of the policy this timestamp was created under.
-
#serial_number ⇒ Object
Returns serial number of the timestamp token.
-
#to_der ⇒ Object
Returns the TokenInfo in DER-encoded form.
- #to_text ⇒ Object
-
#version ⇒ Object
Returns the version number of the token info.
Constructor Details
#initialize(der) ⇒ Object
Creates a TokenInfo from a File or string parameter, the corresponding File or string must be DER-encoded. Please note that TokenInfo is an immutable read-only class. If you’d like to create timestamps please refer to Factory instead.
call-seq:
OpenSSL::Timestamp::TokenInfo.new(file) -> token-info
OpenSSL::Timestamp::TokenInfo.new(string) -> token-info
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 |
# File 'ext/openssl/ossl_ts.c', line 876
static VALUE
ossl_ts_token_info_initialize(VALUE self, VALUE der)
{
TS_TST_INFO *info = DATA_PTR(self);
BIO *in;
der = ossl_to_der_if_possible(der);
in = ossl_obj2bio(&der);
info = d2i_TS_TST_INFO_bio(in, &info);
BIO_free(in);
if (!info) {
DATA_PTR(self) = NULL;
ossl_raise(eTimestampError, "Error when decoding the timestamp token info");
}
DATA_PTR(self) = info;
return self;
}
|
Instance Method Details
#algorithm ⇒ Object
Returns the ‘short name’ of the object identifier representing the algorithm that was used to derive the message imprint digest. For valid timestamps, this is the same value that was already given in the Request. If status is GRANTED or GRANTED_WITH_MODS, this is never nil.
Example:
algo = token_info.algorithm
puts algo -> "SHA1"
call-seq:
token_info.algorithm -> string or nil
946 947 948 949 950 951 952 953 954 955 956 957 958 959 |
# File 'ext/openssl/ossl_ts.c', line 946
static VALUE
ossl_ts_token_info_get_algorithm(VALUE self)
{
TS_TST_INFO *info;
TS_MSG_IMPRINT *mi;
X509_ALGOR *algo;
const ASN1_OBJECT *obj;
GetTSTokenInfo(self, info);
mi = TS_TST_INFO_get_msg_imprint(info);
algo = TS_MSG_IMPRINT_get_algo(mi);
X509_ALGOR_get0(&obj, NULL, NULL, algo);
return ossl_asn1obj_to_string(obj);
}
|
#gen_time ⇒ Object
Returns time when this timestamp token was created. If status is GRANTED or GRANTED_WITH_MODS, this is never nil.
call-seq:
token_info.gen_time -> Time
1013 1014 1015 1016 1017 1018 1019 1020 |
# File 'ext/openssl/ossl_ts.c', line 1013
static VALUE
ossl_ts_token_info_get_gen_time(VALUE self)
{
TS_TST_INFO *info;
GetTSTokenInfo(self, info);
return asn1time_to_time(TS_TST_INFO_get_time(info));
}
|
#message_imprint ⇒ Object
Returns the message imprint digest. For valid timestamps, this is the same value that was already given in the Request. If status is GRANTED or GRANTED_WITH_MODS, this is never nil.
Example:
mi = token_info.msg_imprint
puts mi -> "DEADBEEF"
call-seq:
token_info.msg_imprint -> string.
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 |
# File 'ext/openssl/ossl_ts.c', line 973
static VALUE
ossl_ts_token_info_get_msg_imprint(VALUE self)
{
TS_TST_INFO *info;
TS_MSG_IMPRINT *mi;
ASN1_OCTET_STRING *hashed_msg;
VALUE ret;
GetTSTokenInfo(self, info);
mi = TS_TST_INFO_get_msg_imprint(info);
hashed_msg = TS_MSG_IMPRINT_get_msg(mi);
ret = asn1str_to_str(hashed_msg);
return ret;
}
|
#nonce ⇒ Object
If the timestamp token is valid then this field contains the same nonce that was passed to the timestamp server in the initial Request.
call-seq:
token_info.nonce -> BN or nil
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
# File 'ext/openssl/ossl_ts.c', line 1055
static VALUE
ossl_ts_token_info_get_nonce(VALUE self)
{
TS_TST_INFO *info;
const ASN1_INTEGER *nonce;
GetTSTokenInfo(self, info);
if (!(nonce = TS_TST_INFO_get_nonce(info)))
return Qnil;
return asn1integer_to_num(nonce);
}
|
#ordering ⇒ Object
If the ordering field is missing, or if the ordering field is present and set to false, then the genTime field only indicates the time at which the time-stamp token has been created by the TSA. In such a case, the ordering of time-stamp tokens issued by the same TSA or different TSAs is only possible when the difference between the genTime of the first time-stamp token and the genTime of the second time-stamp token is greater than the sum of the accuracies of the genTime for each time-stamp token.
If the ordering field is present and set to true, every time-stamp token from the same TSA can always be ordered based on the genTime field, regardless of the genTime accuracy.
call-seq:
token_info.ordering -> true, falses or nil
1039 1040 1041 1042 1043 1044 1045 1046 |
# File 'ext/openssl/ossl_ts.c', line 1039
static VALUE
ossl_ts_token_info_get_ordering(VALUE self)
{
TS_TST_INFO *info;
GetTSTokenInfo(self, info);
return TS_TST_INFO_get_ordering(info) ? Qtrue : Qfalse;
}
|
#policy_id ⇒ Object
Returns the timestamp policy object identifier of the policy this timestamp was created under. If status is GRANTED or GRANTED_WITH_MODS, this is never nil.
Example:
id = token_info.policy_id
puts id -> "1.2.3.4.5"
call-seq:
token_info.policy_id -> string or nil
924 925 926 927 928 929 930 931 |
# File 'ext/openssl/ossl_ts.c', line 924
static VALUE
ossl_ts_token_info_get_policy_id(VALUE self)
{
TS_TST_INFO *info;
GetTSTokenInfo(self, info);
return ossl_asn1obj_to_string(TS_TST_INFO_get_policy_id(info));
}
|
#serial_number ⇒ Object
Returns serial number of the timestamp token. This value shall never be the same for two timestamp tokens issued by a dedicated timestamp authority. If status is GRANTED or GRANTED_WITH_MODS, this is never nil.
call-seq:
token_info.serial_number -> BN or nil
997 998 999 1000 1001 1002 1003 1004 |
# File 'ext/openssl/ossl_ts.c', line 997
static VALUE
ossl_ts_token_info_get_serial_number(VALUE self)
{
TS_TST_INFO *info;
GetTSTokenInfo(self, info);
return asn1integer_to_num(TS_TST_INFO_get_serial(info));
}
|
#to_der ⇒ Object
Returns the TokenInfo in DER-encoded form.
call-seq:
token_info.to_der -> string
1074 1075 1076 1077 1078 1079 1080 1081 |
# File 'ext/openssl/ossl_ts.c', line 1074
static VALUE
ossl_ts_token_info_to_der(VALUE self)
{
TS_TST_INFO *info;
GetTSTokenInfo(self, info);
return asn1_to_der((void *)info, (int (*)(void *, unsigned char **))i2d_TS_TST_INFO);
}
|
#to_text ⇒ Object
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 |
# File 'ext/openssl/ossl_ts.c', line 1083
static VALUE
ossl_ts_token_info_to_text(VALUE self)
{
TS_TST_INFO *info;
BIO *out;
GetTSTokenInfo(self, info);
out = BIO_new(BIO_s_mem());
if (!out) ossl_raise(eTimestampError, NULL);
if (!TS_TST_INFO_print_bio(out, info)) {
BIO_free(out);
ossl_raise(eTimestampError, NULL);
}
return ossl_membio2str(out);
}
|
#version ⇒ Object
Returns the version number of the token info. With compliant servers, this value should be 1 if present. If status is GRANTED or GRANTED_WITH_MODS.
call-seq:
token_info.version -> Integer or nil
903 904 905 906 907 908 909 910 |
# File 'ext/openssl/ossl_ts.c', line 903
static VALUE
ossl_ts_token_info_get_version(VALUE self)
{
TS_TST_INFO *info;
GetTSTokenInfo(self, info);
return LONG2NUM(TS_TST_INFO_get_version(info));
}
|