internal static IStrongNameKeyInfo LoadStrongNameKeyData(Stream targetStream, bool @private = true) { if (@private) { PrivateKeyData targetData = new PrivateKeyData(); using (var targetReader = new BinaryReader(targetStream)) targetData.Read(targetReader); var data = targetData.GetData(); StrongNamePrivateKeyInfo result = new StrongNamePrivateKeyInfo(data.Item3, data.Item2, data.Item1, (int)targetData.header.BitLength); return(result); } else { PublicKeyData targetData = new PublicKeyData(); using (var targetReader = new BinaryReader(targetStream)) targetData.Read(targetReader); return(targetData); } }
internal static IStrongNameKeyInfo LoadStrongNameKeyData(byte[] data, bool @private = true) { if (@private) { using (MemoryStream targetStream = new MemoryStream(data)) { PrivateKeyData targetData = new PrivateKeyData(); using (var targetReader = new BinaryReader(targetStream)) targetData.Read(targetReader); var resultData = targetData.GetData(); StrongNamePrivateKeyInfo result = new StrongNamePrivateKeyInfo(resultData.Item3, resultData.Item2, resultData.Item1, (int)targetData.header.BitLength); return(result); } } else { if (data.SequenceEqual(StandardPublicKey)) { return(StandardPublicKeyStream.StandardPublicKey); } else if (PublicKeyData.IsDataProperLength(data)) { using (MemoryStream targetStream = new MemoryStream(data)) { PublicKeyData targetData = new PublicKeyData(); using (var targetReader = new BinaryReader(targetStream)) targetData.Read(targetReader); return(targetData); } } else { throw new ArgumentException("publicKey"); } } }