public static RSA_Verify ( byte data, byte sig, |
||
data | byte | The data to verify |
sig | byte | The signature to verify with |
pubKey | The public key to use to verify | |
Résultat | bool |
/// <summary> /// Verify the signature of packed candidate data /// </summary> /// <param name="packed">The packed candidate data</param> /// <param name="pubKey">The public key to verify with</param> /// <returns></returns> public static bool VerifySignature(byte[] packed, RSAParameters pubKey) { var sig = Arrays.CopyOfRange(packed, packed.Length - 512, packed.Length); var data = Arrays.CopyOfRange(packed, 0, packed.Length - 512); return(Crypto.RSA_Verify(data, sig, pubKey)); }
/// <summary> /// Unpack storable data to a CandidateOldVersionRecord /// </summary> /// <param name="packed">The packed OldVersionRecord data</param> /// <param name="pubKey">The public key to verify with</param> /// <returns>The record object</returns> public static CandidateOldVersionRecord Unpack(byte[] packed, RSAParameters pubKey) { var sig = Arrays.CopyOfRange(packed, packed.Length - 512, packed.Length); var data = Arrays.CopyOfRange(packed, 0, packed.Length - 512); var prefix = Arrays.CopyOfRange(packed, 0, CandidateOldVersionPrefix.Length); if (!Crypto.RSA_Verify(data, sig, pubKey)) { throw new DataVerifyException("Could not cryptographically verify candidate update record"); } data = Arrays.CopyOfRange(data, CandidateOldVersionPrefix.Length, data.Length); if (!Bytes.Equality(CandidateOldVersionPrefix, prefix) || packed.Length != ChainIdLength * 2 + 512 + CandidateOldVersionPrefix.Length) { throw new RecordDataInvalidException("Invalid data provided for packed candidate update record"); } return(new CandidateOldVersionRecord(Arrays.CopyOfRange(data, 0, ChainIdLength), Arrays.CopyOfRange(data, ChainIdLength, ChainIdLength * 2))); }