//Construct a new instance. see crypto/aes
// returning a block cipher that satisfies the crypto/cipher.Block interface
Construct a new instance. see crypto/aes
returning a block cipher that satisfies the crypto/cipher.Block interface
// Construct a new instance . see crypto / aes // returning a block cipher that satisfies the crypto / cipher . Block interface
func NewCipher(key []byte) (cipher.Block, error) {
	aes := new(aesKey)
	key_p := pointerFromBytes(key)
	key_bits := C.int(len(key) * 8)
	if ret := C.AES_set_encrypt_key(key_p, key_bits, &aes._aes_encrypt_key); ret != 0 {
		if err := sslerr.Error(); err != nil {
			return aes, err
		}
		if ret == -1 {
			return aes, errorInvalidKey
		}
		if ret == -2 {
			return aes, errorWrongSizeKey
		}
		return aes, errorSettingKey
	}
	if ret := C.AES_set_decrypt_key(key_p, key_bits, &aes._aes_decrypt_key); ret != 0 {
		if err := sslerr.Error(); err != nil {
			return aes, err
		}
		if ret == -1 {
			return aes, errorInvalidKey
		}
		if ret == -2 {
			return aes, errorWrongSizeKey
		}
		return aes, errorSettingKey
	}
	return aes, nil
}
func NewCipher ( key [ ] byte ) ( cipher . Block , error ) { aes := new ( aesKey ) key_p := pointerFromBytes ( key ) key_bits := C . int ( len ( key ) * 8 ) if ret := C . AES_set_encrypt_key ( key_p , key_bits , & aes . _aes_encrypt_key ) ; ret != 0 { if err := sslerr . Error ( ) ; err != nil { return aes , err } if ret == - 1 { return aes , errorInvalidKey } if ret == - 2 { return aes , errorWrongSizeKey } return aes , errorSettingKey } if ret := C . AES_set_decrypt_key ( key_p , key_bits , & aes . _aes_decrypt_key ) ; ret != 0 { if err := sslerr . Error ( ) ; err != nil { return aes , err } if ret == - 1 { return aes , errorInvalidKey } if ret == - 2 { return aes , errorWrongSizeKey } return aes , errorSettingKey } return aes , nil }
Construct a new instance.
Construct a new instance .
// in case the error is something deep in OpenSSL land // standard fallback error // in case the error is something deep in OpenSSL land // standard fallback error