react-native-fast-rsa icon indicating copy to clipboard operation
react-native-fast-rsa copied to clipboard

Encoding Uint8Array to message string

Open elliotsayes opened this issue 3 years ago • 1 comments

Hi, I'm having a little trouble converting my data to use in the RSA.signPSS function. I've worked out that the signature parameter should be a base64 string, but I can't work out how to encode the message parameter when trying to sign arbitrary Uint8Array data. I've tried Buffer.from(messageBytes).toString() and B64js.fromByteArray(messageBytes) but neither seem to work.

TL;DR Could someone help me with handling signing of Uint8Array messages?

elliotsayes avatar Aug 03 '22 04:08 elliotsayes

@jerson @elliotsayes Uint8Array type should be supported by default when signing - calculation of message offset in both signPSS and signPKCS1v15 is based on flatbuffer instance with createString method, which accepts and processes Uint8Array correctly - in my case just passing it to function returned correct signing to me, the only change which is required there to make it work properly is to just add Uint8Array type to message parameter.

Vadko avatar Sep 24 '24 21:09 Vadko