public void When_Passing_Null_To_Deserialize_Function_With_Private_Key_Then_Exception_Is_Thrown() { // ARRANGE InitializeFakeObjects(); // ACT & ASSERT Assert.Throws <ArgumentNullException>(() => _cngKeySerializer.DeserializeCngKeyWithPrivateKey(null)); }
public string SignWithEllipseCurve(string serializedKeys, string combinedJwsNotSigned) { if (string.IsNullOrWhiteSpace(serializedKeys)) { throw new ArgumentNullException("serializedKeys"); } if (string.IsNullOrWhiteSpace(combinedJwsNotSigned)) { throw new ArgumentNullException("combinedJwsNotSigned"); } var cngKey = _cngKeySerializer.DeserializeCngKeyWithPrivateKey(serializedKeys); var plainTextBytes = Encoding.UTF8.GetBytes(combinedJwsNotSigned); using (var ec = new ECDsaCng(cngKey)) { return(ec .SignData(plainTextBytes, 0, plainTextBytes.Count()) .Base64EncodeBytes()); // return ec.SignData(plainTextBytes).Base64EncodeBytes(); } }