lists.arthurdejong.org
RSS feed

python-pskc branch master updated. 0.5-25-gdcf1919

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-pskc branch master updated. 0.5-25-gdcf1919



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-pskc".

The branch, master has been updated
       via  dcf19199c4e79fab0e279d813a8abf0bb7d9d623 (commit)
       via  364e93de64906f804139d2cddc1973e1b7ae5b14 (commit)
      from  4c5e04612937c95409056818c13f60e1221a773a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-pskc/commit/?id=dcf19199c4e79fab0e279d813a8abf0bb7d9d623

commit dcf19199c4e79fab0e279d813a8abf0bb7d9d623
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Wed Dec 13 22:36:04 2017 +0100

    Add support for KW-Camellia suite of algorithms

diff --git a/pskc/crypto/aeskw.py b/pskc/crypto/aeskw.py
index 84e6f85..a3e2188 100644
--- a/pskc/crypto/aeskw.py
+++ b/pskc/crypto/aeskw.py
@@ -45,7 +45,7 @@ RFC3394_IV = binascii.a2b_hex('a6a6a6a6a6a6a6a6')
 RFC5649_IV = binascii.a2b_hex('a65959a6')
 
 
-def wrap(plaintext, key, iv=None, pad=None):
+def wrap(plaintext, key, iv=None, pad=None, algorithm=algorithms.AES):
     """Apply the AES key wrap algorithm to the plaintext.
 
     The iv can specify an initial value, otherwise the value from RFC 3394 or
@@ -72,7 +72,7 @@ def wrap(plaintext, key, iv=None, pad=None):
         else:
             iv = RFC3394_IV
 
-    cipher = Cipher(algorithms.AES(key), modes.ECB(), default_backend())
+    cipher = Cipher(algorithm(key), modes.ECB(), default_backend())
     encryptor = cipher.encryptor()
     n = len(plaintext) // 8
 
@@ -90,7 +90,7 @@ def wrap(plaintext, key, iv=None, pad=None):
     return A + b''.join(R)
 
 
-def unwrap(ciphertext, key, iv=None, pad=None):
+def unwrap(ciphertext, key, iv=None, pad=None, algorithm=algorithms.AES):
     """Apply the AES key unwrap algorithm to the ciphertext.
 
     The iv can specify an initial value, otherwise the value from RFC 3394 or
@@ -105,7 +105,7 @@ def unwrap(ciphertext, key, iv=None, pad=None):
     if len(ciphertext) % 8 != 0 or (pad is False and len(ciphertext) < 24):
         raise DecryptionError('Ciphertext length wrong')
 
-    cipher = Cipher(algorithms.AES(key), modes.ECB(), default_backend())
+    cipher = Cipher(algorithm(key), modes.ECB(), default_backend())
     decryptor = cipher.decryptor()
     n = len(ciphertext) // 8 - 1
 
diff --git a/pskc/encryption.py b/pskc/encryption.py
index a204a51..6d20daa 100644
--- a/pskc/encryption.py
+++ b/pskc/encryption.py
@@ -51,6 +51,10 @@ def algorithm_key_lengths(algorithm):
             algorithm.endswith('#camellia192-cbc') or
             algorithm.endswith('#camellia256-cbc')):
         return [int(algorithm[-7:-4]) // 8]
+    elif (algorithm.endswith('#kw-camellia128') or
+            algorithm.endswith('#kw-camellia192') or
+            algorithm.endswith('#kw-camellia256')):
+        return [int(algorithm[-3:]) // 8]
     else:
         raise DecryptionError('Unsupported algorithm: %r' % algorithm)
 
@@ -100,10 +104,15 @@ def decrypt(algorithm, key, ciphertext, iv=None):
     elif algorithm.endswith('#kw-tripledes'):
         from pskc.crypto.tripledeskw import unwrap
         return unwrap(ciphertext, key)
-    elif (algorithm.endswith('#camellia128-cbc') or  # pragma: no branch
+    elif (algorithm.endswith('#camellia128-cbc') or
             algorithm.endswith('#camellia192-cbc') or
             algorithm.endswith('#camellia256-cbc')):
         return _decrypt_cbc(algorithms.Camellia, key, ciphertext, iv)
+    elif (algorithm.endswith('#kw-camellia128') or  # pragma: no branch
+            algorithm.endswith('#kw-camellia192') or
+            algorithm.endswith('#kw-camellia256')):
+        from pskc.crypto.aeskw import unwrap
+        return unwrap(ciphertext, key, algorithm=algorithms.Camellia)
     # no fallthrough because algorithm_key_lengths() fails with unknown algo
 
 
@@ -147,10 +156,15 @@ def encrypt(algorithm, key, plaintext, iv=None):
     elif algorithm.endswith('#kw-tripledes'):
         from pskc.crypto.tripledeskw import wrap
         return wrap(plaintext, key)
-    elif (algorithm.endswith('#camellia128-cbc') or  # pragma: no branch
+    elif (algorithm.endswith('#camellia128-cbc') or
             algorithm.endswith('#camellia192-cbc') or
             algorithm.endswith('#camellia256-cbc')):
         return _encrypt_cbc(algorithms.Camellia, key, plaintext, iv)
+    elif (algorithm.endswith('#kw-camellia128') or  # pragma: no branch
+            algorithm.endswith('#kw-camellia192') or
+            algorithm.endswith('#kw-camellia256')):
+        from pskc.crypto.aeskw import wrap
+        return wrap(plaintext, key, algorithm=algorithms.Camellia)
     # no fallthrough because algorithm_key_lengths() fails with unknown algo
 
 
diff --git a/tests/encryption/kw-camellia128.pskcxml 
b/tests/encryption/kw-camellia128.pskcxml
new file mode 100644
index 0000000..8927c36
--- /dev/null
+++ b/tests/encryption/kw-camellia128.pskcxml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Test that holds an kw-camellia128 encrypted value. The encryption key is
+  e35b135a09bfff8b314a5a0c32193c37 and the resulting plaintext should be
+  12345678901234567890.
+-->
+
+<KeyContainer Version="1.0"
+  xmlns="urn:ietf:params:xml:ns:keyprov:pskc"
+  xmlns:xenc="http://www.w3.org/2001/04/xmlenc#";>
+ <EncryptionKey>
+  <KeyName xmlns="http://www.w3.org/2000/09/xmldsig#";>Pre-shared-key</KeyName>
+ </EncryptionKey>
+ <KeyPackage>
+  <Key>
+   <Data>
+    <Secret>
+     <EncryptedValue>
+      <xenc:EncryptionMethod 
Algorithm="http://www.w3.org/2001/04/xmlenc#kw-camellia128"/>
+      <xenc:CipherData>
+       
<xenc:CipherValue>WB128TBZ1WGZzPNJNbwNrWRqQceU7M4FQSJPy2nw6iI=</xenc:CipherValue>
+      </xenc:CipherData>
+     </EncryptedValue>
+    </Secret>
+   </Data>
+  </Key>
+ </KeyPackage>
+</KeyContainer>
diff --git a/tests/encryption/kw-camellia192.pskcxml 
b/tests/encryption/kw-camellia192.pskcxml
new file mode 100644
index 0000000..6efc0a8
--- /dev/null
+++ b/tests/encryption/kw-camellia192.pskcxml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Test that holds an kw-camellia192 encrypted value. The encryption key is
+  5eb0bccad29abe52d143d5aebc1c1ba174b8d379ce763c28 and the resulting
+  plaintext should be 12345678901234567890.
+-->
+
+<KeyContainer Version="1.0"
+  xmlns="urn:ietf:params:xml:ns:keyprov:pskc"
+  xmlns:xenc="http://www.w3.org/2001/04/xmlenc#";>
+ <EncryptionKey>
+  <KeyName xmlns="http://www.w3.org/2000/09/xmldsig#";>Pre-shared-key</KeyName>
+ </EncryptionKey>
+ <KeyPackage>
+  <Key>
+   <Data>
+    <Secret>
+     <EncryptedValue>
+      <xenc:EncryptionMethod 
Algorithm="http://www.w3.org/2001/04/xmlenc#kw-camellia192"/>
+      <xenc:CipherData>
+       
<xenc:CipherValue>y/wSpn3aNjeXzY1giHLOy0P+WQ+NmkN7EovBtHBXZ14=</xenc:CipherValue>
+      </xenc:CipherData>
+     </EncryptedValue>
+    </Secret>
+   </Data>
+  </Key>
+ </KeyPackage>
+</KeyContainer>
diff --git a/tests/encryption/kw-camellia256.pskcxml 
b/tests/encryption/kw-camellia256.pskcxml
new file mode 100644
index 0000000..4a6a155
--- /dev/null
+++ b/tests/encryption/kw-camellia256.pskcxml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Test that holds an kw-camellia256 encrypted value. The encryption key is
+  0e187c656c36975b0d6bded79d7089142209457114ce8e6f4ae78339d71114e8 and the
+  resulting plaintext should be 12345678901234567890.
+-->
+
+<KeyContainer Version="1.0"
+  xmlns="urn:ietf:params:xml:ns:keyprov:pskc"
+  xmlns:xenc="http://www.w3.org/2001/04/xmlenc#";>
+ <EncryptionKey>
+  <KeyName xmlns="http://www.w3.org/2000/09/xmldsig#";>Pre-shared-key</KeyName>
+ </EncryptionKey>
+ <KeyPackage>
+  <Key>
+   <Data>
+    <Secret>
+     <EncryptedValue>
+      <xenc:EncryptionMethod 
Algorithm="http://www.w3.org/2001/04/xmlenc#kw-camellia256"/>
+      <xenc:CipherData>
+       
<xenc:CipherValue>tCrhhD62tBGCcbsp8GV91+79MhaXTy1MP1SkaT2OLaU=</xenc:CipherValue>
+      </xenc:CipherData>
+     </EncryptedValue>
+    </Secret>
+   </Data>
+  </Key>
+ </KeyPackage>
+</KeyContainer>
diff --git a/tests/test_encryption.doctest b/tests/test_encryption.doctest
index 7f6ebd3..f2ab455 100644
--- a/tests/test_encryption.doctest
+++ b/tests/test_encryption.doctest
@@ -163,6 +163,36 @@ DecryptionError: Invalid key length
 'X7We+WREABNPa0jlsUHZqF5CWUQiPYdXJ+7ure96AcNH/7TXcQs4mFuSCOHpiv/W'
 
 
+>>> pskc = PSKC('tests/encryption/kw-camellia128.pskcxml')
+>>> pskc.encryption.key = a2b_hex('e35b135a09bfff8b314a5a0c32193c37')
+>>> pskc.encryption.algorithm
+'http://www.w3.org/2001/04/xmldsig-more#kw-camellia128'
+>>> tostr(pskc.keys[0].secret)
+'12345678901234567890'
+>>> tostr(base64.b64encode(encrypt(pskc.encryption.algorithm, 
pskc.encryption.key, pskc.keys[0].secret)))
+'WB128TBZ1WGZzPNJNbwNrWRqQceU7M4FQSJPy2nw6iI='
+
+
+>>> pskc = PSKC('tests/encryption/kw-camellia192.pskcxml')
+>>> pskc.encryption.key = 
a2b_hex('5eb0bccad29abe52d143d5aebc1c1ba174b8d379ce763c28')
+>>> pskc.encryption.algorithm
+'http://www.w3.org/2001/04/xmldsig-more#kw-camellia192'
+>>> tostr(pskc.keys[0].secret)
+'12345678901234567890'
+>>> tostr(base64.b64encode(encrypt(pskc.encryption.algorithm, 
pskc.encryption.key, pskc.keys[0].secret)))
+'y/wSpn3aNjeXzY1giHLOy0P+WQ+NmkN7EovBtHBXZ14='
+
+
+>>> pskc = PSKC('tests/encryption/kw-camellia256.pskcxml')
+>>> pskc.encryption.key = 
a2b_hex('0e187c656c36975b0d6bded79d7089142209457114ce8e6f4ae78339d71114e8')
+>>> pskc.encryption.algorithm
+'http://www.w3.org/2001/04/xmldsig-more#kw-camellia256'
+>>> tostr(pskc.keys[0].secret)
+'12345678901234567890'
+>>> tostr(base64.b64encode(encrypt(pskc.encryption.algorithm, 
pskc.encryption.key, pskc.keys[0].secret)))
+'tCrhhD62tBGCcbsp8GV91+79MhaXTy1MP1SkaT2OLaU='
+
+
 The IV can also be specified globally.
 
 >>> pskc = PSKC('tests/encryption/aes128-cbc-noiv.pskcxml')

https://arthurdejong.org/git/python-pskc/commit/?id=364e93de64906f804139d2cddc1973e1b7ae5b14

commit 364e93de64906f804139d2cddc1973e1b7ae5b14
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Wed Dec 13 19:55:38 2017 +0100

    Add support for Camellia-CBC suite of algorithms

diff --git a/pskc/encryption.py b/pskc/encryption.py
index d90476c..a204a51 100644
--- a/pskc/encryption.py
+++ b/pskc/encryption.py
@@ -47,6 +47,10 @@ def algorithm_key_lengths(algorithm):
             algorithm.endswith('#kw-aes192') or \
             algorithm.endswith('#kw-aes256'):
         return [int(algorithm[-3:]) // 8]
+    elif (algorithm.endswith('#camellia128-cbc') or
+            algorithm.endswith('#camellia192-cbc') or
+            algorithm.endswith('#camellia256-cbc')):
+        return [int(algorithm[-7:-4]) // 8]
     else:
         raise DecryptionError('Unsupported algorithm: %r' % algorithm)
 
@@ -93,9 +97,13 @@ def decrypt(algorithm, key, ciphertext, iv=None):
             algorithm.endswith('#kw-aes256'):
         from pskc.crypto.aeskw import unwrap
         return unwrap(ciphertext, key)
-    elif algorithm.endswith('#kw-tripledes'):  # pragma: no branch
+    elif algorithm.endswith('#kw-tripledes'):
         from pskc.crypto.tripledeskw import unwrap
         return unwrap(ciphertext, key)
+    elif (algorithm.endswith('#camellia128-cbc') or  # pragma: no branch
+            algorithm.endswith('#camellia192-cbc') or
+            algorithm.endswith('#camellia256-cbc')):
+        return _decrypt_cbc(algorithms.Camellia, key, ciphertext, iv)
     # no fallthrough because algorithm_key_lengths() fails with unknown algo
 
 
@@ -136,9 +144,13 @@ def encrypt(algorithm, key, plaintext, iv=None):
             algorithm.endswith('#kw-aes256'):
         from pskc.crypto.aeskw import wrap
         return wrap(plaintext, key)
-    elif algorithm.endswith('#kw-tripledes'):  # pragma: no branch
+    elif algorithm.endswith('#kw-tripledes'):
         from pskc.crypto.tripledeskw import wrap
         return wrap(plaintext, key)
+    elif (algorithm.endswith('#camellia128-cbc') or  # pragma: no branch
+            algorithm.endswith('#camellia192-cbc') or
+            algorithm.endswith('#camellia256-cbc')):
+        return _encrypt_cbc(algorithms.Camellia, key, plaintext, iv)
     # no fallthrough because algorithm_key_lengths() fails with unknown algo
 
 
diff --git a/tests/encryption/camellia128-cbc.pskcxml 
b/tests/encryption/camellia128-cbc.pskcxml
new file mode 100644
index 0000000..bbf4567
--- /dev/null
+++ b/tests/encryption/camellia128-cbc.pskcxml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Test that holds an camellia128-cbc encrypted value. Encryption key is
+  200497e673a6fae2256e9749468a67ac.
+-->
+
+<KeyContainer Version="1.0"
+  xmlns="urn:ietf:params:xml:ns:keyprov:pskc"
+  xmlns:ds="http://www.w3.org/2000/09/xmldsig#";
+  xmlns:xenc="http://www.w3.org/2001/04/xmlenc#";>
+ <EncryptionKey>
+  <ds:KeyName>Pre-shared-key</ds:KeyName>
+ </EncryptionKey>
+ <MACMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#hmac-sha224";>
+  <MACKey>
+   <xenc:EncryptionMethod 
Algorithm="http://www.w3.org/2001/04/xmlenc#camellia128-cbc"/>
+   <xenc:CipherData>
+    
<xenc:CipherValue>VnWO9OoCQWEuH0qsz1VnywNqjvXC/kUNcMp8cFfCqiw48doVY9XVcMV0GR5vn6g3</xenc:CipherValue>
+   </xenc:CipherData>
+  </MACKey>
+ </MACMethod>
+ <KeyPackage>
+  <Key>
+   <Data>
+    <Secret>
+     <EncryptedValue>
+      <xenc:EncryptionMethod 
Algorithm="http://www.w3.org/2001/04/xmlenc#camellia128-cbc"/>
+      <xenc:CipherData>
+       
<xenc:CipherValue>DvtlFS8/QZle2xG8PjfA8Kg4bsjLlU8kH/sEfXC9VLWib2Z/WU8RDHR+fI9uCqOs</xenc:CipherValue>
+      </xenc:CipherData>
+     </EncryptedValue>
+     <ValueMAC>RDATcSJh3n8TAvMDoPzKqobgOCPZSluA7Gmvpg==</ValueMAC>
+    </Secret>
+   </Data>
+  </Key>
+ </KeyPackage>
+</KeyContainer>
diff --git a/tests/encryption/camellia192-cbc.pskcxml 
b/tests/encryption/camellia192-cbc.pskcxml
new file mode 100644
index 0000000..0365a10
--- /dev/null
+++ b/tests/encryption/camellia192-cbc.pskcxml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Test that holds an camellia192-cbc encrypted value. Encryption key is
+  e263279877384c84c987661a9d06766affdb9b3211eae801.
+-->
+
+<KeyContainer Version="1.0"
+  xmlns="urn:ietf:params:xml:ns:keyprov:pskc"
+  xmlns:ds="http://www.w3.org/2000/09/xmldsig#";
+  xmlns:xenc="http://www.w3.org/2001/04/xmlenc#";>
+ <EncryptionKey>
+  <ds:KeyName>Pre-shared-key</ds:KeyName>
+ </EncryptionKey>
+ <MACMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#hmac-sha224";>
+  <MACKey>
+   <xenc:EncryptionMethod 
Algorithm="http://www.w3.org/2001/04/xmlenc#camellia192-cbc"/>
+   <xenc:CipherData>
+    
<xenc:CipherValue>WAL6YRtYa5/rE/DX26NKXaHpDu2qE4q5kdtCZmvhZeHMsV76CuLlO5ybTD9RsLWK</xenc:CipherValue>
+   </xenc:CipherData>
+  </MACKey>
+ </MACMethod>
+ <KeyPackage>
+  <Key>
+   <Data>
+    <Secret>
+     <EncryptedValue>
+      <xenc:EncryptionMethod 
Algorithm="http://www.w3.org/2001/04/xmlenc#camellia192-cbc"/>
+      <xenc:CipherData>
+       
<xenc:CipherValue>Wa5Kz1/BhuqUcpQyw8qRSDwurIsm2vjUR/PO3w1Q3//PFfHod+DgBhRW2BecWpP5</xenc:CipherValue>
+      </xenc:CipherData>
+     </EncryptedValue>
+     <ValueMAC>RDATcSJh3n8TAvMDoPzKqobgOCPZSluA7Gmvpg==</ValueMAC>
+    </Secret>
+   </Data>
+  </Key>
+ </KeyPackage>
+</KeyContainer>
diff --git a/tests/encryption/camellia256-cbc.pskcxml 
b/tests/encryption/camellia256-cbc.pskcxml
new file mode 100644
index 0000000..59911aa
--- /dev/null
+++ b/tests/encryption/camellia256-cbc.pskcxml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Test that holds an camellia256-cbc encrypted value. Encryption key is
+  33b37e31c5a0a16f004e7fe727d4ff808fc1f879d85ccd8f06dbb5799565d2f5.
+-->
+
+<KeyContainer Version="1.0"
+  xmlns="urn:ietf:params:xml:ns:keyprov:pskc"
+  xmlns:ds="http://www.w3.org/2000/09/xmldsig#";
+  xmlns:xenc="http://www.w3.org/2001/04/xmlenc#";>
+ <EncryptionKey>
+  <ds:KeyName>Pre-shared-key</ds:KeyName>
+ </EncryptionKey>
+ <MACMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#hmac-sha224";>
+  <MACKey>
+   <xenc:EncryptionMethod 
Algorithm="http://www.w3.org/2001/04/xmlenc#camellia256-cbc"/>
+   <xenc:CipherData>
+    
<xenc:CipherValue>uj9VFSjENtykiBdHoxF/CZ8y2XnWA/fW89i4xonEH9iYK2AH0/hkH7bVmI2ObcSa</xenc:CipherValue>
+   </xenc:CipherData>
+  </MACKey>
+ </MACMethod>
+ <KeyPackage>
+  <Key>
+   <Data>
+    <Secret>
+     <EncryptedValue>
+      <xenc:EncryptionMethod 
Algorithm="http://www.w3.org/2001/04/xmlenc#camellia256-cbc"/>
+      <xenc:CipherData>
+       
<xenc:CipherValue>X7We+WREABNPa0jlsUHZqF5CWUQiPYdXJ+7ure96AcNH/7TXcQs4mFuSCOHpiv/W</xenc:CipherValue>
+      </xenc:CipherData>
+     </EncryptedValue>
+     <ValueMAC>RDATcSJh3n8TAvMDoPzKqobgOCPZSluA7Gmvpg==</ValueMAC>
+    </Secret>
+   </Data>
+  </Key>
+ </KeyPackage>
+</KeyContainer>
diff --git a/tests/test_encryption.doctest b/tests/test_encryption.doctest
index 7e1d443..7f6ebd3 100644
--- a/tests/test_encryption.doctest
+++ b/tests/test_encryption.doctest
@@ -130,6 +130,39 @@ DecryptionError: Invalid key length
 '2923bf85e06dd6ae529149f1f1bae9eab3a7da3d860d3e98'
 
 
+>>> pskc = PSKC('tests/encryption/camellia128-cbc.pskcxml')
+>>> pskc.encryption.key = a2b_hex('200497e673a6fae2256e9749468a67ac')
+>>> pskc.encryption.algorithm
+'http://www.w3.org/2001/04/xmldsig-more#camellia128-cbc'
+>>> tostr(pskc.keys[0].secret)
+'12345678901234567890'
+>>> tostr(base64.b64encode(encrypt(pskc.encryption.algorithm, 
pskc.encryption.key,
+...     pskc.keys[0].secret, a2b_hex('0efb65152f3f41995edb11bc3e37c0f0'))))
+'DvtlFS8/QZle2xG8PjfA8Kg4bsjLlU8kH/sEfXC9VLWib2Z/WU8RDHR+fI9uCqOs'
+
+
+>>> pskc = PSKC('tests/encryption/camellia192-cbc.pskcxml')
+>>> pskc.encryption.key = 
a2b_hex('e263279877384c84c987661a9d06766affdb9b3211eae801')
+>>> pskc.encryption.algorithm
+'http://www.w3.org/2001/04/xmldsig-more#camellia192-cbc'
+>>> tostr(pskc.keys[0].secret)
+'12345678901234567890'
+>>> tostr(base64.b64encode(encrypt(pskc.encryption.algorithm, 
pskc.encryption.key,
+...     pskc.keys[0].secret, a2b_hex('59AE4ACF5FC186EA94729432C3CA9148'))))
+'Wa5Kz1/BhuqUcpQyw8qRSDwurIsm2vjUR/PO3w1Q3//PFfHod+DgBhRW2BecWpP5'
+
+
+>>> pskc = PSKC('tests/encryption/camellia256-cbc.pskcxml')
+>>> pskc.encryption.key = 
a2b_hex('33b37e31c5a0a16f004e7fe727d4ff808fc1f879d85ccd8f06dbb5799565d2f5')
+>>> pskc.encryption.algorithm
+'http://www.w3.org/2001/04/xmldsig-more#camellia256-cbc'
+>>> tostr(pskc.keys[0].secret)
+'12345678901234567890'
+>>> tostr(base64.b64encode(encrypt(pskc.encryption.algorithm, 
pskc.encryption.key,
+...     pskc.keys[0].secret, a2b_hex('5FB59EF9644400134F6B48E5B141D9A8'))))
+'X7We+WREABNPa0jlsUHZqF5CWUQiPYdXJ+7ure96AcNH/7TXcQs4mFuSCOHpiv/W'
+
+
 The IV can also be specified globally.
 
 >>> pskc = PSKC('tests/encryption/aes128-cbc-noiv.pskcxml')

-----------------------------------------------------------------------

Summary of changes:
 pskc/crypto/aeskw.py                               |  8 +--
 pskc/encryption.py                                 | 30 ++++++++++-
 ...r-plaintext.pskcxml => camellia128-cbc.pskcxml} | 13 +++--
 ...r-plaintext.pskcxml => camellia192-cbc.pskcxml} | 13 +++--
 ...r-plaintext.pskcxml => camellia256-cbc.pskcxml} | 13 +++--
 .../{kw-aes128.pskcxml => kw-camellia128.pskcxml}  | 10 ++--
 .../{kw-aes128.pskcxml => kw-camellia192.pskcxml}  | 10 ++--
 .../{kw-aes128.pskcxml => kw-camellia256.pskcxml}  | 10 ++--
 tests/test_encryption.doctest                      | 63 ++++++++++++++++++++++
 9 files changed, 128 insertions(+), 42 deletions(-)
 copy tests/encryption/{mac-over-plaintext.pskcxml => camellia128-cbc.pskcxml} 
(66%)
 copy tests/encryption/{mac-over-plaintext.pskcxml => camellia192-cbc.pskcxml} 
(66%)
 copy tests/encryption/{mac-over-plaintext.pskcxml => camellia256-cbc.pskcxml} 
(66%)
 copy tests/encryption/{kw-aes128.pskcxml => kw-camellia128.pskcxml} (66%)
 copy tests/encryption/{kw-aes128.pskcxml => kw-camellia192.pskcxml} (64%)
 copy tests/encryption/{kw-aes128.pskcxml => kw-camellia256.pskcxml} (63%)


hooks/post-receive
-- 
python-pskc
-- 
To unsubscribe send an email to
python-pskc-commits-unsubscribe@lists.arthurdejong.org or see
https://lists.arthurdejong.org/python-pskc-commits/