~/bend-docscommunity

kex.bend checks

raw source on the hub · import bend-osdev-crypto@0.1.0.0/kex.bend as Kex

The key-agreement interface.

A key agreement (template arguments, in this order): ~SK: Data a secret key ~PK: Data a public key ~secret: B.Octets -> Result<&2, &2, CrError, SK> a secret key from its bytes, refusing a malformed one ~public: SK -> PK its public key ~pk_of: B.Octets -> Result<&2, &2, CrError, PK> a peer's public key from its bytes (CrBadPublicKey) ~pk_to: PK -> B.Octets a public key's bytes ~shared: SK -> PK -> Result<&2, &2, CrError, B.Octets> the shared secret, or the refusal of a peer key the scheme rejects (CrBadKey) Laws (README.md, "Laws"): agree shared(a, public(b)) == shared(b, public(a)), for every two secret keys: both sides compute the same secret pk_format pk_of(pk_to(p)) == Done{p}

No algorithm of bend-osdev is a key agreement yet; one plugs in by supplying these defs (README.md, "Extension points"). A shared secret is keying material for a KDF (kdf.bend), not a key.

3 imports
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B
import ./crypto.bend as Cr

Templates

template cr.kex.with source · line 31 · raw

@-SK:Data -> @-PK:Data -> @-shared:(@_:SK -> @_:PK -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>) -> @sk:Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, SK> -> @pk:Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, PK> -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>

template CrKex.agree source · line 42 · raw

@-SK:Data -> @-PK:Data -> @-secret:(@_:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, SK>) -> @-pk_of:(@_:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, PK>) -> @-shared:(@_:SK -> @_:PK -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>) -> @sk:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @peer:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>

The shared secret of one's secret key's bytes and the peer's public key's bytes