github.com/trustbloc/kms-go@v1.1.2/secretlock/local/internal/cipher/util_test.go (about)

     1  /*
     2  Copyright SecureKey Technologies Inc. All Rights Reserved.
     3  SPDX-License-Identifier: Apache-2.0
     4  */
     5  
     6  package cipher
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/stretchr/testify/require"
    12  )
    13  
    14  func TestCreateAESCipherWithLongKey(t *testing.T) {
    15  	veryLongMK := make([]byte, 99)
    16  	for i := range veryLongMK {
    17  		veryLongMK[i] = 'a'
    18  	}
    19  
    20  	mk, err := CreateAESCipher(veryLongMK)
    21  	require.Error(t, err)
    22  	require.Empty(t, mk)
    23  }
    24  
    25  func TestCreateAESCipherWithValidKey(t *testing.T) {
    26  	mkWithValidSize := make([]byte, 32)
    27  	for i := range mkWithValidSize {
    28  		mkWithValidSize[i] = 'a'
    29  	}
    30  
    31  	mk, err := CreateAESCipher(mkWithValidSize)
    32  	require.NoError(t, err)
    33  	require.NotEmpty(t, mk)
    34  }