Documentation
¶
Overview ¶
Package bundlesign signs a bundle of the kinds of request, and verifies such a signature.
A bundle is a zip of a requests directory and its Wasm module. What is signed is not the zip's bytes directly but a short text: the fixed prefix line "ringi bundle v1", then the SHA-256 of the whole bundle as one line of lower-case hexadecimal. The digest keeps the signature small and independent of how large the bundle is; the prefix keeps a signature of a bundle from being read as a signature of anything else. The signature file holds the 64-byte ed25519 signature of that line in standard base64, as one line.
Sign makes the signature file's content with a private key, and Verify checks it with public keys. ReadPrivateKey and ReadPublicKeys read the keys in the PEM forms common tools write (PKCS#8 and PKIX). The package uses the standard library alone.
A server checks a bundle's signature only when its configuration lists ed25519 public keys. Without such a list, a bundle is not refused for having no signature; the server's other checks and approvals decide whether it is taken.
Index ¶
- func Digest(bundle []byte) string
- func KeyFingerprint(key ed25519.PublicKey) string
- func ReadPrivateKey(pemData []byte) (ed25519.PrivateKey, error)
- func ReadPublicKeys(pemData []byte) ([]ed25519.PublicKey, error)
- func Sign(key ed25519.PrivateKey, bundle []byte) []byte
- func Verify(keys []ed25519.PublicKey, bundle []byte, sig []byte) error
- func VerifyKey(keys []ed25519.PublicKey, bundle []byte, sig []byte) (ed25519.PublicKey, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyFingerprint ¶
KeyFingerprint names a key: the SHA-256 of its bytes, in lower-case hexadecimal. It names the key, not what it signed, so that a store can record which key signed a bundle without keeping the key.
func ReadPrivateKey ¶
func ReadPrivateKey(pemData []byte) (ed25519.PrivateKey, error)
ReadPrivateKey reads one PEM block of type "PRIVATE KEY", a private key in the PKCS#8 form crypto/x509.MarshalPKCS8PrivateKey and common tools write. It refuses data that is not exactly one such block, and a key that is not ed25519.
func ReadPublicKeys ¶
ReadPublicKeys reads one or more PEM blocks of type "PUBLIC KEY", each a public key in the PKIX form crypto/x509.MarshalPKIXPublicKey and common tools write. It refuses a block of another type, a key that is not ed25519, data outside the blocks, and data with no block.
func Sign ¶
func Sign(key ed25519.PrivateKey, bundle []byte) []byte
Sign answers the content of the signature file for bundle: the 64-byte ed25519 signature in standard base64, one line ending with a newline. key is a private key as ed25519.GenerateKey or ReadPrivateKey answers it.
func Verify ¶
Verify checks that sig is the content of a signature file for bundle made by one of keys. It answers nil when any key verifies it. The file may end at the base64 line, or with a newline or CRLF; anything else around the base64 is refused.
Types ¶
This section is empty.