Documentation
¶
Overview ¶
Package credentials implements necessary functions to cooperate with ActiveSupport::EncryptedConfiguration. See active_support/encrypted_configuration.rb(https://github.com/rails/rails/blob/04df9bc3d120b51447bde54caa56e9237cb8da0e/activesupport/lib/active_support/encrypted_configuration.rb) for the reference implementation.
Index ¶
- Constants
- Variables
- func Decrypt(MasterKey string, EncryptedFileContent string) (DecryptedFileContent []byte, err error)
- func Encrypt(MasterKey string, RawFileContent []byte) (EncryptedFileContent string, err error)
- func MarshalSingleString(source string) ([]byte, error)
- func NewCredentialsFileContent() (string, error)
- func RandomMasterKey() (string, error)
- func SanitizeMasterKey(in string) string
- func UnmarshalSingleString(marshalledObject []byte) (string, error)
Constants ¶
const ( // Separator for the encrypted content, IV and tag. // https://github.com/rails/rails/blob/04df9bc3d120b51447bde54caa56e9237cb8da0e/activesupport/lib/active_support/message_encryptor.rb#L119 Separator = "--" GcmStandardNonceSize = 12 // https://github.com/rails/rails/blob/04df9bc3d120b51447bde54caa56e9237cb8da0e/activesupport/lib/active_support/message_encryptor.rb#L118 GcmTagSize = 16 )
const (
CredentialsFileContentTemplate = `` /* 246-byte string literal not displayed */
)
const ( // MasterKeyLengthBytes is the length of the master key in bytes. // AES-128-GCM requires a 16-byte key. MasterKeyLengthBytes = 16 )
Variables ¶
var Base64Encoding = base64.StdEncoding
Functions ¶
func Decrypt ¶
func Decrypt(MasterKey string, EncryptedFileContent string) (DecryptedFileContent []byte, err error)
Decrypt decrypts the encrypted file content using the master key. The master key should be a hex-encoded string of 32 hex characters (16 bytes). The encrypted file content is expected to be in the format: <base64-encoded-content><Separator><base64-encoded-iv><Separator><base64-encoded-tag> The content is encrypted using AES-128-GCM.
func MarshalSingleString ¶
MarshalSingleString converts a string into Ruby marshal format.
func NewCredentialsFileContent ¶
NewCredentialsFileContent generates a credentials.yml example. This function is only used in the TUI.
func RandomMasterKey ¶
RandomMasterKey generates a random master key.
func SanitizeMasterKey ¶
func UnmarshalSingleString ¶
UnmarshalSingleString extracts a single string from a Ruby marshalled object. The string must be the first item. Everything else is discarded.
Types ¶
This section is empty.