INNER CODE UNIT · Go

ConvertKey

cryptag/cryptag · encrypt_decrypt.go:57

func ConvertKey(key []byte) (goodKey *[32]byte, err error) {
	if len(key) != validKeyLength {
		return nil, fmt.Errorf("Invalid key; must be of length %d, has length %d",
			validKeyLength, len(key))
	}

	// []byte -> *[32]byte
	var good [validKeyLength]byte
	copy(good[:], key)

	return &good, nil
}

func UnconvertKey(goodKey *[32]byte) ([]byte, error) {
	if goodKey == nil {
		return nil, ErrNilKey
	}
	return (*goodKey)[:], nil

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…