aes_ctr_cipher_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package osscrypto
  2. import (
  3. . "gopkg.in/check.v1"
  4. )
  5. func (s *OssCryptoBucketSuite) TestContentEncryptCipherError(c *C) {
  6. // crypto bucket
  7. masterRsaCipher, _ := CreateMasterRsa(matDesc, rsaPublicKey, rsaPrivateKey)
  8. contentProvider := CreateAesCtrCipher(masterRsaCipher)
  9. cc, err := contentProvider.ContentCipher()
  10. c.Assert(err, IsNil)
  11. var cipherData CipherData
  12. cipherData.RandomKeyIv(31, 15)
  13. _, err = cc.Clone(cipherData)
  14. c.Assert(err, NotNil)
  15. }
  16. func (s *OssCryptoBucketSuite) TestCreateCipherDataError(c *C) {
  17. // crypto bucket
  18. masterRsaCipher, _ := CreateMasterRsa(matDesc, "", "")
  19. contentProvider := CreateAesCtrCipher(masterRsaCipher)
  20. v := contentProvider.(aesCtrCipherBuilder)
  21. _, err := v.createCipherData()
  22. c.Assert(err, NotNil)
  23. }
  24. func (s *OssCryptoBucketSuite) TestContentCipherCDError(c *C) {
  25. var cd CipherData
  26. // crypto bucket
  27. masterRsaCipher, _ := CreateMasterRsa(matDesc, "", "")
  28. contentProvider := CreateAesCtrCipher(masterRsaCipher)
  29. v := contentProvider.(aesCtrCipherBuilder)
  30. _, err := v.contentCipherCD(cd)
  31. c.Assert(err, NotNil)
  32. }