wrappingkey

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WrappingKey

type WrappingKey struct{}

func (WrappingKey) DeserializeEncryptedDataKey

func (wk WrappingKey) DeserializeEncryptedDataKey(b []byte, iVLen int) (encryptedData, iv []byte)

DeserializeEncryptedDataKey reverses the process of SerializeEncryptedDataKey. It takes a single byte slice containing the serialized encrypted data key, tag, and IV and extracts the original components. This is typically used to retrieve the encrypted key and IV for decryption purposes.

Parameters:

b      []byte: A byte slice that contains the serialized encrypted data key,
                authentication tag, and IV.
iVLen  int:    The length of the IV, which dictates how many bytes to extract
                from the end of the byte slice for the IV.

Returns:

encryptedData []byte: The portion of the byte slice 'b' that represents the
                      encrypted data key (and potentially the authentication
                      tag if it is included with the encrypted data).
iv            []byte: The extracted initialization vector that was originally
                      used for encryption.

func (WrappingKey) SerializeEncryptedDataKey

func (wk WrappingKey) SerializeEncryptedDataKey(encryptedKey, tag, iv []byte) []byte

SerializeEncryptedDataKey takes three separate byte slices that represent the encrypted key, the authentication tag, and the initialization vector (IV), and concatenates them into a single byte slice.

Parameters:

encryptedKey []byte: A byte slice representing the encrypted data key.
tag          []byte: A byte slice representing the authentication tag
                     used to verify the integrity of the encrypted data.
iv           []byte: A byte slice representing the initialization vector
                     used during the encryption process.

Returns:

[]byte: A concatenated byte slice that includes the encrypted key, followed
        by the authentication tag, and ending with the IV.

func (WrappingKey) SerializeKeyInfoPrefix

func (wk WrappingKey) SerializeKeyInfoPrefix(keyID string) []byte

SerializeKeyInfoPrefix is a method of the WrappingKey struct. It takes a keyID string as input and returns a byte slice.

The method first creates a byte slice, keyInfoPrefix, with a length equal to the length of the keyID string plus twice the length of a uint32 in big endian format. It then copies the keyID string into the start of the keyInfoPrefix byte slice. Next, it converts the tag length (tagLen) multiplied by the size of a byte (oneByte) into a uint32 in big endian format and copies this into the keyInfoPrefix byte slice, starting at the position after the keyID. Finally, it converts the initialization vector length (ivLen) into a uint32 in big endian format and copies this into the keyInfoPrefix byte slice, starting at the position after the keyID and the tag length.

Parameters:

keyID string: A string representing the key ID.

Returns:

[]byte: A byte slice that includes the key ID, followed by the tag length
        and the initialization vector length, all in big endian format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL