libsodium-bindings-0.0.1.1: FFI bindings to libsodium
Copyright(C) Hécate Moonlight 2022
LicenseBSD-3-Clause
MaintainerThe Haskell Cryptography Group
StabilityStable
PortabilityGHC only
Safe HaskellNone
LanguageHaskell2010

LibSodium.Bindings.KeyExchange

Description

 
Synopsis

Introduction

The key exchange API allows two parties to securely compute a set of shared keys using their peer's public key, and their own secret key.

Key Exchange

Key generation

cryptoKXKeyPair Source #

Arguments

:: Ptr CUChar

The buffer that will hold the public key, of size cryptoKXPublicKeyBytes.

-> Ptr CUChar

The buffer that will hold the secret key, of size cryptoKXSecretKeyBytes.

-> IO CInt

Returns 0 on success, -1 on error.

Create a new key pair.

This function takes pointers to two empty buffers that will hold (respectively) the public and secret keys.

See: crypto_kx_keypair()

Since: 0.0.1.0

cryptoKXSeedKeypair Source #

Arguments

:: Ptr CUChar

The buffer that will hold the public key, of size cryptoKXPublicKeyBytes.

-> Ptr CUChar

The buffer that will hold the secret key, of size cryptoKXSecretKeyBytes.

-> Ptr CUChar

The pointer to the seed from which the keys are derived. It is of size cryptoKXSeedBytes bytes.

-> IO CInt

Returns 0 on success, -1 on error.

Create a new key pair from a seed.

This function takes pointers to two empty buffers that will hold (respectively) the public and secret keys, as well as the seed from which these keys will be derived.

See: crypto_kx_seed_keypair()

Since: 0.0.1.0

Client

cryptoKXClientSessionKeys Source #

Arguments

:: Ptr CUChar

A pointer to the buffer that will hold the shared secret key, of size cryptoKXSessionKeyBytes bytes.

-> Ptr CUChar

A pointer to the buffer that will hold the shared public key, of size cryptoKXSessionKeyBytes bytes.

-> Ptr CUChar

A pointer to the client's public key, of size cryptoKXPublicKeyBytes bytes.

-> Ptr CUChar

A pointer to the client's secret key, of size cryptoKXSecretKeyBytes bytes.

-> Ptr CUChar

A pointer to the server's public key, of size cryptoKXPublicKeyBytes bytes.

-> IO CInt

Returns 0 on success, -1 on error, such as when the server's public key is not acceptable.

Compute a pair of shared session keys (secret and public).

These session keys are computed using:

  • The client's public key
  • The client's secret key
  • The server's public key

The shared secret key should be used by the client to receive data from the server, whereas the shared public key should be used for data flowing to the server.

If only one session key is required, either the pointer to the shared secret key or the pointer to the shared public key can be set to nullPtr.

See: crypto_kx_client_session_keys()

Since: 0.0.1.0

Server

cryptoKXServerSessionKeys Source #

Arguments

:: Ptr CUChar

A pointer to the buffer that will hold the shared secret key, of size cryptoKXSessionKeyBytes bytes.

-> Ptr CUChar

A pointer to the buffer that will hold the shared public key, of size cryptoKXSessionKeyBytes bytes.

-> Ptr CUChar

A pointer to the server's public key, of size cryptoKXPublicKeyBytes bytes.

-> Ptr CUChar

A pointer to the server's secret key, of size cryptoKXSecretKeyBytes bytes.

-> Ptr CUChar

A pointer to the client's public key, of size cryptoKXPublicKeyBytes bytes.

-> IO CInt

Returns 0 on success, -1 on error, such as when the server's public key is not acceptable.

Compute a pair of shared session keys (secret and public).

These session keys are computed using:

  • The server's public key
  • The server's secret key
  • The client's public key

The shared secret key should be used by the server to receive data from the client, whereas the shared public key should be used for data flowing to the client.

If only one session key is required, either the pointer to the shared secret key or the pointer to the shared public key can be set to nullPtr.

See: crypto_kx_server_session_keys()

Since: 0.0.1.0

Constants

cryptoKXPublicKeyBytes :: CSize Source #

Size of the public key in bytes.

See: crypto_kx_PUBLICKEYBYTES

Since: 0.0.1.0

cryptoKXSecretKeyBytes :: CSize Source #

Size of the secret key in bytes.

See: crypto_kx_SECRETKEYBYTES

Since: 0.0.1.0

cryptoKXSeedBytes :: CSize Source #

Size of the seed in bytes.

See: crypto_kx_SEEDBYTES

Since: 0.0.1.0

cryptoKXSessionKeyBytes :: CSize Source #

Size of the session key in bytes.

See: crypto_kx_SESSIONKEYBYTES

Since: 0.0.1.0

cryptoKXPrimitive :: Ptr CChar Source #

Primitive used by this module

See: crypto_kx_PRIMITIVE

Since: 0.0.1.0