IDX10603 Decryption failed.. Keys tried [PII is hidden]Parameter name: KeySize

Today in this article, we will see how to fix error “System.ArgumentOutOfRangeException: IDX10603: Decryption failed. Keys tried : ‘[PII is hidden]’.Exceptions caught: ‘[PII is hidden]’. token: ‘[PII is hidden]’ Parameter name: KeySize'”

Issue Description

JWT Security handler produces an error while Validating the JWT Token from the .NET C# code.

System.ArgumentOutOfRangeException: 'IDX10603: Decryption failed. Keys tried: '[PII is hidden]'.Exceptions caught:  '[PII is hidden]'. token: '[PII is hidden]' Parameter name: KeySize'

SystemArgumentOutOfRangeException'IDX10603: Decryption failed. Keys tried:'[PII is hidden]'.Exceptions caught:'[PII is hidden]'. token:'[PII is hidden]' Parameter name: KeySize'

sample secret key in the sample above used was below,

"JwtToken": {
    "SecretKey": "xecretKeywqe",
    "Issuer": "https://localhost:44378",
  }

Resolution

As indicated in the error code “Parameter Name: Key Size” was causing this issue.

This issue was found to be due to limitations of the SecretKey length used in the SymmetricSecurityKey before signing and generating the signed credentials.

Therefore it’s recommended to use a 128-bit key, generated with cryptographic algorithms.

Reference RFC2104

For .NET/.NET Core, the key Secret key should be a minimum of 128 bits i.e (16 bytes).

In my example, the original key length was smaller than 16 characters i.e less than 16 bytes producing the above error.

After increasing the key size above 16 characters in ASCII text format gave me 128 bits above key size thereby fixing the issue.

Updated keys to minimum 16 characters i.e 16 bytes as below,

"JwtToken": {
    "SecretKey": "xecretKeywqejane",
    "Issuer": "https://localhost:44378"
  }

IDX10603 Decryption failed

Finally, with the above changes, the issue resolves.

References :

Did the above steps resolve your issue? Please sound off in the comments below!



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



10 thoughts on “Resolved- IDX10603 Decryption failed. Keys tried [PII is hidden]Parameter name: KeySize

Leave a Reply

Your email address will not be published. Required fields are marked *