Documentation
¶
Index ¶
- func DecodeBase64URL(s string) ([]byte, error)
- func DecryptAESGCM(ciphertext []byte, salt []byte, serverPubKeyBytes []byte, ...) ([]byte, error)
- func DecryptMessage(payload []byte, privateKey *ecdh.PrivateKey, authSecret []byte) ([]byte, error)
- func EncodeBase64URL(data []byte) string
- func GenerateAuthSecret() ([]byte, error)
- func GenerateInstanceID() ([]byte, error)
- type KeyPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeBase64URL ¶
DecodeBase64URL decodes a base64url string without padding.
func DecryptAESGCM ¶
func DecryptAESGCM(ciphertext []byte, salt []byte, serverPubKeyBytes []byte, privateKey *ecdh.PrivateKey, authSecret []byte) ([]byte, error)
DecryptAESGCM decrypts a Web Push message encrypted with the older aesgcm scheme (draft-ietf-webpush-encryption). The salt and server public key come from the HTTP headers (Encryption and Crypto-Key), not from the payload itself.
func DecryptMessage ¶
DecryptMessage decrypts a Web Push message encrypted with RFC 8291 (aes128gcm).
func EncodeBase64URL ¶
EncodeBase64URL encodes bytes to base64url without padding.
func GenerateAuthSecret ¶
GenerateAuthSecret generates a 16-byte random auth secret for Web Push.
func GenerateInstanceID ¶
GenerateInstanceID generates an 8-byte instance ID with first nibble set to 0x7 (Chrome convention).
Types ¶
type KeyPair ¶
type KeyPair struct {
PrivateKey *ecdh.PrivateKey
PublicKey *ecdh.PublicKey
}
KeyPair holds an ECDH P-256 key pair for Web Push.
func GenerateKeyPair ¶
GenerateKeyPair generates a new ECDH P-256 key pair.
func PrivateKeyFromBytes ¶
PrivateKeyFromBytes reconstructs an ECDH P-256 private key from raw 32 bytes.