Exemple #1
0
        public static unsafe byte *SigningKeyToEncryptionKey(IKeyFileService keyFileService, IKeyCapture capture)
        {
            var sk = keyFileService.GetSecretKeyPointer(capture);

            try
            {
                return(SigningKeyToEncryptionKey(sk));
            }
            finally
            {
                NativeMethods.sodium_free(sk);
            }
        }
Exemple #2
0
 public static byte[] SigningPublicKeyFromSigningKey(IKeyFileService keyFileService, IKeyCapture capture)
 {
     unsafe
     {
         var sk = keyFileService.GetSecretKeyPointer(capture);
         try
         {
             var ed25519PublicKey = new byte[PublicKeyBytes];
             SigningPublicKeyFromSigningKey(sk, ed25519PublicKey);
             return(ed25519PublicKey);
         }
         finally
         {
             NativeMethods.sodium_free(sk);
         }
     }
 }
        public void Sign(IKeyFileService keyFileService, IKeyCapture capture,
                         ulong formatVersion = LogSerializeContext.FormatVersion)
        {
            unsafe
            {
                var sk      = keyFileService.GetSecretKeyPointer(capture);
                var message = GetMessage(formatVersion);

                var signature       = new byte[Crypto.SecretKeyBytes].AsSpan();
                var signatureLength = Crypto.SignDetached(message, sk, signature);
                if (signatureLength < (ulong)signature.Length)
                {
                    signature = signature.Slice(0, (int)signatureLength);
                }

                Signature = signature.ToArray();
            }
        }
 internal static byte[] GenerateKeyFile(ITestOutputHelper output, IKeyCapture capture, IKeyFileService service)
 {
     lock (Sync)
     {
         var @out  = new XunitDuplexTextWriter(output, Console.Out);
         var error = new XunitDuplexTextWriter(output, Console.Error);
         Assert.True(KeyFileManager.TryGenerateKeyFile(service.GetKeyFileStream(), @out, error, capture));
         capture.Reset();
         return(Crypto.SigningPublicKeyFromSigningKey(service, capture));
     }
 }