示例#1
0
        public override byte[] ToPvk()
        {
            var blob = new RsaPrivateKeyBlob(ToRsaParameters());
            var key  = blob.ToArray();
            var pvk  = new PrivateKeyFile {
                KeyType   = 2,
                Encrypted = 0,
                SaltLen   = 0,
                Key       = key
            };

            return(pvk.ToArray());
        }
示例#2
0
        public static PrivateKeyFile ReadFrom(Stream stream)
        {
            using (var reader = new BinaryReader(stream, Encoding.UTF8, true)) {
                var res = new PrivateKeyFile {
                    Magic     = reader.ReadUInt32(),
                    Reserved  = reader.ReadUInt32(),
                    KeyType   = reader.ReadUInt32(),
                    Encrypted = reader.ReadUInt32(),
                    SaltLen   = reader.ReadUInt32(),
                };

                var keyLen = reader.ReadUInt32();
                res.Key = reader.ReadBytes((int)keyLen);
                return(res);
            }
        }