tsa_rfc3161 1.0.2
tsa_rfc3161: ^1.0.2 copied to clipboard
This is a TSA (Time Stamping Authority) client/library RFC3161 for Flutter apps. With it, you can timestamp any files or any text message
Flutter TSA (Time Stamping Authority) client rfc3161 #
tested on macos and android configurations with digicert and certigna tsa (fails with flutter web if TSA host does not provide CORS header)
import 'package:dio/dio.dart';
import 'package:tsa_rfc3161/tsa_rfc3161.dart';
// ...
TSARequest tsq = TSARequest.fromFile(
filepath: file.path,
algorithm: TSAHashAlgo.sha512,
nonce: nonceValue,
certReq: true);
// for a string use
// TSARequest tsq = TSARequest.fromString(s: "yannick", algorithm: TSAHashAlgo.sha512);
Response response = await tsq.run(hostname: "http://timestamp.digicert.com");
if (response.statusCode == 200) {
TSAResponse tsr = TSAResponse.fromHTTPResponse(response: response);
}
Note 1
tsq.asn1sequence.encodedBytes is similar to the content of file.digicert.tsq generated by openssl
openssl ts -query -data file.txt -no_nonce -sha512 -cert -out file.digicert.tsq
Note 2
the content of response.data is similar to the content of file.digicert.tsr generated by digicert's http server
curl -H 'Content-Type: application/timestamp-query' --data-binary '@file.digicert.tsq' http://timestamp.digicert.com > file.digicert.tsr
Note 3
authentication is available
Response response = await tsq.run(
hostname: "https://timestamp.dhimyotis.com/api/v1/",
credentials: "$user:$password");
Note 4
TSAResponse tsr = TSAResponse.fromHTTPResponse(response: response);
tsr.write("test.tsr");
you have now a test.tsr you can look with a openssl cli command
$ openssl ts -reply -in test.tsr -text provides
Version: 1
Policy OID: 2.16.840.1.114412.7.1
Hash Algorithm: sha512
Message data:
0000 - 89 bd 94 b7 92 4b 2f 16-d8 c5 c0 0f 11 02 12 b1 .....K/.........
0010 - bb b1 5a bb 72 7d be 06-33 bf 7d d0 9f 6f d6 07 ..Z.r}..3.}..o..
0020 - 02 4d a3 df d6 7b cf c7-89 e2 2f 2d d9 fa 9b c3 .M...{..../-....
0030 - 39 9a d4 34 11 e1 11 d8-c6 7b a7 a0 b4 96 42 2d 9..4.....{....B-
Serial number: 0x4194EF54150D2496B2C3F1A78D82C41B
Time stamp: Sep 7 08:37:47 2024 GMT
Accuracy: unspecified
Ordering: no
Nonce: 0x0191CBA1D914
TSA: unspecified
Extensions: