class: RegressionTests::CryptTests
authorClaus Gittinger <cg@exept.de>
Mon, 02 Dec 2013 19:13:14 +0100
changeset 1035 2be1f5b478ca
parent 1034 19a7bdfbe204
child 1036 c42c54df984e
class: RegressionTests::CryptTests added: #test11_rsaKey
RegressionTests__CryptTests.st
--- a/RegressionTests__CryptTests.st	Mon Dec 02 19:09:38 2013 +0100
+++ b/RegressionTests__CryptTests.st	Mon Dec 02 19:13:14 2013 +0100
@@ -3,10 +3,10 @@
 "{ NameSpace: RegressionTests }"
 
 TestCase subclass:#CryptTests
-	instanceVariableNames:''
-	classVariableNames:''
-	poolDictionaries:''
-	category:'tests-Regression'
+        instanceVariableNames:''
+        classVariableNames:''
+        poolDictionaries:''
+        category:'tests-Regression'
 !
 
 !CryptTests class methodsFor:'documentation'!
@@ -280,6 +280,42 @@
     "
 
     "Modified: / 25-11-2013 / 11:45:34 / cg"
+!
+
+test11_rsaKey
+    |dir fn key ks plain cipher|
+
+    dir := Smalltalk packageDirectoryForPackageId:'exept:expecco'.
+    self skipIf:dir isNil description:'directory with test key is not present'.
+    fn := dir asFilename construct:'license/expeccoKey.pem'.
+    self skipIf:fn exists not description:'test key is not present'.
+
+    key := RSASecretCryptKey fromPemStream:fn readStream.
+
+    ks := RSACryptStream new.
+    ks encryptWithSecretKey:true.
+    ks key:key.
+    ks stream:#[] writeStream.
+
+    plain := '12345678901234567890'.
+    ks encrypt:plain.
+    cipher := ks stream contents.
+
+    ks := RSACryptStream new.
+    ks encryptWithSecretKey:true.
+    ks key:key.
+    ks stream:#[] writeStream.
+
+    ks decrypt:cipher.
+
+    self assert:(ks stream contents asString = plain).
+
+    "
+     self run:#test11_rsaKey
+     self new test11_rsaKey
+    "
+
+    "Created: / 02-12-2013 / 12:58:19 / cg"
 ! !
 
 !CryptTests class methodsFor:'documentation'!