I hate commit messages
This commit is contained in:
1 parent
209af0d820
commit
8654c45e35
11 files changed
+278
-35
No files matched your search
@@ -1,3 +1,39 @@
|
||||
package files
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rsa"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/didiercrunch/filou/contract"
|
||||
"github.com/didiercrunch/filou/helper"
|
||||
)
|
||||
|
||||
func getRSAPrivateKey() contract.GetRSAPrivateKey {
|
||||
return func() (*rsa.PrivateKey, error) {
|
||||
return helper.GetRSAPrivateKey(2048), nil
|
||||
}
|
||||
}
|
||||
|
||||
func getSensibleAcceptedContract() *contract.AcceptedContract {
|
||||
ret := new(contract.AcceptedContract)
|
||||
ret.Hash = "sha512"
|
||||
ret.BlockCipher = "aes256"
|
||||
ret.BlockCipherMode = "ofb"
|
||||
ret.AsynchronousEncryptionScheme = "rsa_oaep"
|
||||
ret.SignatureScheme = "rsa_pss"
|
||||
ret.RsaPrivateKey = getRSAPrivateKey()
|
||||
ret.RsaPublicKey = helper.GetRSAPublicKey(2048)
|
||||
return ret
|
||||
}
|
||||
|
||||
func TestEncryptFile(t *testing.T) {
|
||||
buffer := bytes.NewBufferString("some secret text")
|
||||
w := helper.NewMockIoWriter()
|
||||
c := getSensibleAcceptedContract()
|
||||
if err := EncryptFile(buffer, w, c); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
fmt.Println(w.String())
|
||||
}
|
||||
Reference in new issue
Block a user