Пример #1
0
// Description returns the key's description as a string.
func (mk *MetaKey) Description() (d string, err error) {
	tlv, err := mk.fields.Get(tagDescription)
	if tlv != nil {
		d = string(tlv.Value())
	}
	return
}
Пример #2
0
// Expires returns the expiration date as an ANSIC-formatted string.
func (mk *MetaKey) Expires() (e string, err error) {
	tlv, err := mk.fields.Get(tagExpiration)
	if tlv != nil {
		e = string(tlv.Value())
	}
	return
}
Пример #3
0
// GetKey returns the appropriate encryption key for the requested algorithm.
func (mk *MetaKey) GetKey(keySize int) (key []byte, err error) {
	var keyType int

	switch keySize {
	case AES128KeyLength:
		keyType = tagKeyAES128
	case AES192KeyLength:
		keyType = tagKeyAES192
	case AES256KeyLength:
		keyType = tagKeyAES256
	default:
		return key, ErrKeySizeNotSupported
	}

	tlv, err := mk.fields.Get(keyType)
	if err != nil {
		return
	}
	key = tlv.Value()
	return
}