MCPcopy Create free account
hub / github.com/Hidden-Node/GooseRelayVPN-AndroidClient / Seal

Method Seal

internal/frame/crypto.go:55–65  ·  view source on GitHub ↗

Seal encrypts plaintext and returns nonce||ciphertext (tag appended by GCM).

(plaintext []byte)

Source from the content-addressed store, hash-verified

53
54// Seal encrypts plaintext and returns nonce||ciphertext (tag appended by GCM).
55func (c *Crypto) Seal(plaintext []byte) ([]byte, error) {
56 nonce := make([]byte, c.aead.NonceSize())
57 if _, err := rand.Read(nonce); err != nil {
58 return nil, fmt.Errorf("crypto: nonce read: %w", err)
59 }
60 ct := c.aead.Seal(nil, nonce, plaintext, nil)
61 out := make([]byte, 0, len(nonce)+len(ct))
62 out = append(out, nonce...)
63 out = append(out, ct...)
64 return out, nil
65}
66
67// Open inverts Seal. Returns an error on auth-tag failure (tampered ciphertext,
68// nonce, or tag, or wrong key).

Calls 1

ReadMethod · 0.45