# RSAVerifySignature with optional RSASignModes parameter

**URL:** <https://forum.xojo.com/t/rsaverifysignature-with-optional-rsasignmodes-parameter/84772>\
**Category:** General\
**Created:** [March 28, 2025, 2:49pm UTC](https://forum.xojo.com/t/rsaverifysignature-with-optional-rsasignmodes-parameter/84772 "2025-03-28T14:49:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Taylor1](https://forum.xojo.com/user_avatar/forum.xojo.com/michael_taylor1/32/4600_2.png) [@Michael\_Taylor1](https://forum.xojo.com/u/Michael_Taylor1)\
**Post date:** [March 28, 2025, 2:49pm UTC](https://forum.xojo.com/t/rsaverifysignature-with-optional-rsasignmodes-parameter/84772/1 "2025-03-28T14:49:17Z")

</div>

Hello,

Does anybody know if the undocumented, optional RSASignModes parameter to the RSAVerifySignature works? I cannot get it to verify a valid SHA512 signature when passing Crypto.RSASignModes.SHA2\_512 for that parameter.

Thank you.

---

<div class="post-metadata">

**Author:** ![Greg\_O](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o/32/22785_2.png) [@Greg\_O](https://forum.xojo.com/u/Greg_O)\
**Post date:** [March 28, 2025, 5:25pm UTC](https://forum.xojo.com/t/rsaverifysignature-with-optional-rsasignmodes-parameter/84772/2 "2025-03-28T17:25:11Z")

</div>

You should provide example code here and file a bug report with Xojo.

---

<div class="post-metadata">

**Author:** ![Michael\_Taylor1](https://forum.xojo.com/user_avatar/forum.xojo.com/michael_taylor1/32/4600_2.png) [@Michael\_Taylor1](https://forum.xojo.com/u/Michael_Taylor1)\
**Post date:** [March 28, 2025, 9:13pm UTC](https://forum.xojo.com/t/rsaverifysignature-with-optional-rsasignmodes-parameter/84772/3 "2025-03-28T21:13:10Z")

</div>

Well, I don’t know if it’s a bug exactly, since the parameter isn’t in the official docs. It’s only in the code completion, so that’s why I’m asking if anybody knows if it’s supported officially.

Here’s a simple code snippet:

```auto
Var PublicKey As String = "-----BEGIN PUBLIC KEY-----" + EndOfLine + _
"..." + EndOfLine + _
"-----END PUBLIC KEY-----"

Var Key As String = PublicKey.Trim
Key = Key.ReplaceAll(Encodings.UTF8.Chr(13) + Encodings.UTF8.Chr(10), Encodings.UTF8.Chr(10))
Key = Key.ReplaceAll(Encodings.UTF8.Chr(13), Encodings.UTF8.Chr(10))

Var Lines() As String = Key.Split(Encodings.UTF8.Chr(10))
Lines.RemoveAt(0)
Lines.RemoveAt(Lines.LastIndex)

Key = String.FromArray(Lines, Encodings.UTF8.Chr(10))
Var DecodedKey As String = DecodeBase64(Key)

// Message is a DesktopTextField
Var data As String = Message.Text.Trim

// Signature is a DesktopTextArea
Var decodedSig As String = Signature.Text
decodedSig = decodedSig.Trim
decodedSig = decodedSig.ReplaceLineEndings("")
decodedSig = decodedSig.ReplaceAll(" ", "")
decodedSig = DecodeBase64(decodedSig)

if Crypto.RSAVerifyKey(EncodeHex(DecodedKey)) then
  // NOTE: The 'Crypto.RSASignModes.SHA2_512' parameter below is the one in question
  If Crypto.RSAVerifySignature(EncodeHex(data), EncodeHex(decodedSig), EncodeHex(DecodedKey), Crypto.RSASignModes.SHA2_512) Then
    Status.Text = "Verified!"
  else
    Status.Text = "BAD signature"
  end
else
  Status.Text = "BAD key"
end

```

Note that the message and signature are valid according to openssl command line tools.

---

<div class="post-metadata">

**Author:** ![Greg\_O](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o/32/22785_2.png) [@Greg\_O](https://forum.xojo.com/u/Greg_O)\
**Post date:** [March 28, 2025, 11:07pm UTC](https://forum.xojo.com/t/rsaverifysignature-with-optional-rsasignmodes-parameter/84772/4 "2025-03-28T23:07:33Z")

</div>

Don’t pass the hex encoded strings. Those are for human eyes. Decode the hex and pass the binary strings to the function
