Answer the question
In order to leave comments, you need to log in
How does RSA+SHA1 digital signature work? How to implement in C#?
Good afternoon!
We integrate with a payment gateway that uses RSA+SHA1 EDS to verify communication with X509 certificates. We have generated a private key + certificate, which we sent to the gateway. The gateway in response generated a certificate on its side and sent two files, CRT and KEY (contains a public key). As far as I understand the signature algorithm, when sending, we first read RSA from the content being signed, using their certificate (public key?), Then we read the sha1 hash from the received cipher. Question:
1) Have I described the process correctly? or are there more steps I'm missing?
2) Does the certificate contain a public key? if so, is the KEY file sent by the gateway needed?
Practical part.
The implementation is done in C#.
var content = "data";
var ctr = new X509Certificate2(filename); // путь до crt-файла присланного шлюзом
var provider = ctr.PublicKey.Key as RSACryptoServiceProvider; // если после этой строки посмотрим на provider, то там действительно есть сертификат длинной 2048
var dta = provider.Encrypt(Encoding.ASCII.GetBytes(content), true); // в dta вроде бы 256 байт
var sig = provider.SignData(dta, "SHA1"); // и тут мы ловим исключение "набор ключей не существует"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question