Vonage / vonage-dotnet-sdk

Vonage REST API client for .NET, written in C#. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
https://developer.vonage.com/
Apache License 2.0
105 stars 82 forks source link

Fix edge case importing RSA key #580

Closed OronDF343 closed 2 months ago

OronDF343 commented 2 months ago

Description

Fixes edge case Exception importing private key when D is shorter in length than MODULUS by 8 bits or more.

If D is shorter, it is copied to the end of a new array with the same length as MODULUS. Naive, but this is a rare edge case.

Motivation and Context

This fixes issue #357 that I just ran into using an older Vonage application private key.

How Has This Been Tested?

Ran unit tests with old and new keys and published to our production server (which uses multiple private keys).

Tr00d commented 2 months ago

Hi @OronDF343,

Thanks for looking into this :clap: The problem didn't occur for a year so, as you said, it's probably related to older keys. PemParse.cs is a tricky one as it was blatantly copied from an obscur source, without any sense of ownership or testing - which is why I tried to stay away from it.

Tr00d commented 2 months ago

@OronDF343, I released v7.6.1, which includes your change. Thanks again for contributing