public static bool Validate(byte[] message, byte[] publicKey, byte[] signatureBytes) { int cb; UInt32 nspk = strTou32(signatureBytes, 0); UInt32 nspkKey = strTou32(publicKey, 0); if (nspk + 1 != nspkKey) { throw new CoseException("Incorrect number of signature layeres for the public key"); } byte[][] sigList = new byte[nspk + 1][]; byte[][] publist = new byte[nspk][]; int offset = 4; for (uint i = 0; i < nspk; i++) { cb = LmsKey.SignatureLength(signatureBytes, offset); sigList[i] = new byte[cb]; Array.Copy(signatureBytes, offset, sigList[i], 0, cb); offset += cb; cb = LmsKey.PublicKeyLength(signatureBytes, offset); publist[i] = new byte[cb]; Array.Copy(signatureBytes, offset, publist[i], 0, cb); offset += cb; } cb = LmsKey.SignatureLength(signatureBytes, offset); sigList[nspk] = new byte[cb]; Array.Copy(signatureBytes, offset, sigList[nspk], 0, cb); byte[] key = new byte[publicKey.Length - 4]; Array.Copy(publicKey, 4, key, 0, key.Length); for (uint i = 0; i < nspk; i++) { if (!LmsKey.Validate(publist[i], key, sigList[i])) { return(false); } Array.Copy(publist[i], key, publist[i].Length); } return(LmsKey.Validate(message, key, sigList[nspk])); }
public static string PrintSignature(byte[] signatureBytes) { UInt32 nspk = strTou32(signatureBytes, 0); string result = ""; int offset = 4; for (uint i = 0; i < nspk; i++) { result += LmsKey.PrintSignature(signatureBytes, ref offset); result += LmsKey.PrintPublicKey(signatureBytes, ref offset); } result += "------------------------------------------------\nfinal signature:\n-----------------------------------"; result += LmsKey.PrintSignature(signatureBytes, ref offset); return(result); }
public HssNode(string[] input, int offset) { privateKey = new LmsKey(input, offset); }
public HssNode(LmsAlgorithmType lmsType, LmotsAlgorithmType lmotsType) { privateKey = new LmsKey(lmsType, lmotsType); }