I
I
Igor2020-03-03 13:43:54
Encryption
Igor, 2020-03-03 13:43:54

How to generate a digest?

There is the following instruction.
I can not understand.


Request headers
X-Signature header
Request electronic signature
To authorize terminal requests and establish authorship, the protocol uses asymmetric cryptographic algorithms with private and public keys:

ECDSA prime256v1
RSA 1024
RSA 2048
The SHA256 hash function is used to generate a message digest. The private key is generated on the terminal side and stored in the crypto storage. The public key is transferred to the Sendy PC during the terminal activation procedure.

Formation of the Electronic Signature (ES)
The body of the transmitted POST request is converted into a digest (hash) using the SHA256 algorithm and passed to the selected crypto algorithm. The received ES must be in the DER format (asn.1 serialized structure) with data on the crypto-algorithm used. Next, the binary ES is converted to a base64 sequence and passed to the request header in the "X-Signature" parameter.


Plug here
The received ES must be in DER format (asn.1 serialized structure)


My steps to achieve the goal:

1. I run the body of the transmitted POST through the SHA256 algorithm. I get a
string like
f5dcbf42be3cf18a87a0fd5127aabd8f5bcc78e96cb1811c0af3c687f350696a


2. Next, the resulting string in the previous step is transmitted to the algorithm ECDSA prime256v1

request body Signature
MEUCIQCCvqg9R1ncDq7aJeSgkjmp7yx50Bm48pCz6CAflWqtyQIgf7A71sv5kK0dEkN1lR / bHQNLaPk0ex2nlCs / brDT + 1Q =

request body signature in base 64
MEUCIEfwIA7UE1OJAlEaSyD46 + 0POQwy8C4lywlwiS7 + SItvAiEAqcwVwcwkRy7sPngLvarshHLoEHHD / QoJZHEwq67Ccm4 =

Next, I went out ...

How does this very DER (asn.1 serialized structure)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lubezniy, 2020-03-03
@lubezniy

ASN.1 - binary format. And the line from the first paragraph is given in hex. Perhaps it should be decoded from hex, and then passed on. Well, the signature of the request body is already in base64, it is hardly worth coding it a second time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question