[libxslt] Add tests for crypto:rc4



commit 5179455c54275bc120b2f2a9201365351d402dd9
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Fri Aug 2 10:55:01 2013 +0200

    Add tests for crypto:rc4

 tests/exslt/crypto/crypt.1.out |   19 +++++++++++++++++++
 tests/exslt/crypto/crypt.1.xml |   19 +++++++++++++++++++
 tests/exslt/crypto/crypt.1.xsl |   32 ++++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/tests/exslt/crypto/crypt.1.out b/tests/exslt/crypto/crypt.1.out
new file mode 100644
index 0000000..b34060c
--- /dev/null
+++ b/tests/exslt/crypto/crypt.1.out
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<test-results>
+  <test-result>
+    <ciphertext>ac81e5869f1cd55ee7146e347b26cdd25274e871f98ea1b8698ea99543db</ciphertext>
+    <match>OK</match>
+  </test-result>
+  <test-result>
+    
<ciphertext>054026a1c66049af4d48d53c152316144a27519d2c6272910c18ad6cb602ede48ceb0b72fecb287019fe7e1a866c2d34d12ec106ffdf3506e5c6a4a211bb62b4dbd67bac018e8f954823eda9c51aae8bb7b531f97363ce1a2065722521962deed7139e6781dd27404ad9fd2fd0668e2ffaf1d8a64c33f13936163adca3caefce423b276ada7f4738412c639b40ed43dd469dc522cdcb9c3232fab96eae0e7d3350b1dea9639d6a488e584323e865e808d966f379df498e887f9c6b70cb9a4fe6561f46e5fb125f4600430d11d517623e891375a43c87857c26060362f2c37331fc010e153736eae80bab728b666ef607fac9e1c62cc43ca32fc35b6ec98381d51c523cdf272b0d64ed6450c4bbc7128d3714e70733a4154fc023c432c21973db9b578d824f3f29af479eb01055fecb0bbd7960f2a2f8875938cad8aecf214bad46f4abd3f68b4d817fa184f74d0ba0c3d267840ed98434e167daa52637fbaaf25b24e1edc6fae1b7e505a7b1d10587c0cce2353e43af5cbdd9df5dbc659756182fcf5355cc289c72e7b4af9f169bf4538ac43062913296eca4817262a351b8002dfb604e20d4fd6d4e055c73c7b58c82ea6ef98a4076bb172110401efdf6</ciphertext>
+    <match>OK</match>
+  </test-result>
+  <test-result>
+    <ciphertext>b9ed4dfb21cdefeb9f79f75068b080ccb9c84ea7279d2aeb574d</ciphertext>
+    <match>OK</match>
+  </test-result>
+  <test-result>
+    <ciphertext>c6d661f83293f0398501e1c0e73b8fa9232e2d167b4f</ciphertext>
+    <match>OK</match>
+  </test-result>
+</test-results>
diff --git a/tests/exslt/crypto/crypt.1.xml b/tests/exslt/crypto/crypt.1.xml
new file mode 100644
index 0000000..4c02521
--- /dev/null
+++ b/tests/exslt/crypto/crypt.1.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test-cases>
+    <test-case>
+        <key>open_sesame</key>
+        <data>Ali Baba and the forty thieves</data>
+    </test-case>
+    <test-case>
+        <key>trustno1</key>
+        <data>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut 
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut 
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore 
eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt 
mollit anim id est laborum.</data>
+    </test-case>
+    <test-case>
+        <key>password</key>
+        <data>Ärger, Ökonom, Übermut.</data>
+    </test-case>
+    <test-case>
+        
<key>01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567</key>
+        <data>Test with 128-byte key</data>
+    </test-case>
+</test-cases>
diff --git a/tests/exslt/crypto/crypt.1.xsl b/tests/exslt/crypto/crypt.1.xsl
new file mode 100644
index 0000000..f986943
--- /dev/null
+++ b/tests/exslt/crypto/crypt.1.xsl
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+    xmlns:crypto="http://exslt.org/crypto";
+    exclude-result-prefixes="crypto"
+    version="1.0">
+
+    <xsl:output indent="yes"/>
+
+    <xsl:template match="test-cases">
+        <test-results>
+            <xsl:apply-templates select="test-case"/>
+        </test-results>
+    </xsl:template>
+
+    <xsl:template match="test-case">
+        <xsl:variable name="ciphertext" select="crypto:rc4_encrypt(key, data)"/>
+        <xsl:variable name="plaintext" select="crypto:rc4_decrypt(key, $ciphertext)"/>
+        <test-result>
+            <ciphertext>
+                <xsl:value-of select="$ciphertext"/>
+            </ciphertext>
+            <match>
+                <xsl:choose>
+                    <xsl:when test="$plaintext = data">OK</xsl:when>
+                    <xsl:otherwise>FAIL</xsl:otherwise>
+                </xsl:choose>
+            </match>
+        </test-result>
+    </xsl:template>
+
+</xsl:stylesheet>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]