[libsecret] mock: Remove unused code



commit 7da8c2b70ed47acf59854406ca931d00f3ff9a90
Author: Dmitry Shachnev <mitya57 gmail com>
Date:   Wed Feb 10 20:21:01 2016 +0300

    mock: Remove unused code
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761834

 libsecret/mock/aes.py     |   58 ---------------------------------------------
 libsecret/mock/hkdf.py    |   14 +----------
 libsecret/mock/service.py |    1 -
 3 files changed, 1 insertions(+), 72 deletions(-)
---
diff --git a/libsecret/mock/aes.py b/libsecret/mock/aes.py
index 2265fab..79b1459 100644
--- a/libsecret/mock/aes.py
+++ b/libsecret/mock/aes.py
@@ -11,8 +11,6 @@
 # Licensed under the Apache License, Version 2.0
 # http://www.apache.org/licenses/
 #
-import os
-import sys
 import math
 
 def append_PKCS7_padding(s):
@@ -587,62 +585,6 @@ class AESModeOfOperation(object):
         return bytes(result)
 
 
-def encryptData(key, data, mode=AESModeOfOperation.modeOfOperation["CBC"]):
-    """encrypt `data` using `key`
-
-    `key` should be a string of bytes.
-
-    returned cipher is a string of bytes prepended with the initialization
-    vector.
-
-    """
-    key = map(ord, key)
-    if mode == AESModeOfOperation.modeOfOperation["CBC"]:
-        data = append_PKCS7_padding(data)
-    keysize = len(key)
-    assert keysize in AES.keySize.values(), 'invalid key size: %s' % keysize
-    # create a new iv using random data
-    iv = [ord(i) for i in os.urandom(16)]
-    moo = AESModeOfOperation()
-    (mode, length, ciph) = moo.encrypt(data, mode, key, keysize, iv)
-    # With padding, the original length does not need to be known. It's a bad
-    # idea to store the original message length.
-    # prepend the iv.
-    return ''.join(map(chr, iv)) + ''.join(map(chr, ciph))
-
-def decryptData(key, data, mode=AESModeOfOperation.modeOfOperation["CBC"]):
-    """decrypt `data` using `key`
-
-    `key` should be a string of bytes.
-
-    `data` should have the initialization vector prepended as a string of
-    ordinal values.
-
-    """
-
-    key = map(ord, key)
-    keysize = len(key)
-    assert keysize in AES.keySize.values(), 'invalid key size: %s' % keysize
-    # iv is first 16 bytes
-    iv = map(ord, data[:16])
-    data = map(ord, data[16:])
-    moo = AESModeOfOperation()
-    decr = moo.decrypt(data, None, mode, key, keysize, iv)
-    if mode == AESModeOfOperation.modeOfOperation["CBC"]:
-        decr = strip_PKCS7_padding(decr)
-    return decr
-
-def generateRandomKey(keysize):
-    """Generates a key from random data of length `keysize`.
-
-    The returned key is a string of bytes.
-
-    """
-    if keysize not in (16, 24, 32):
-        emsg = 'Invalid keysize, %s. Should be one of (16, 24, 32).'
-        raise ValueError(emsg % keysize)
-    return os.urandom(keysize)
-
 if __name__ == "__main__":
     moo = AESModeOfOperation()
     cleartext = "This is a test!"
diff --git a/libsecret/mock/hkdf.py b/libsecret/mock/hkdf.py
index 5e8ee9b..4a967eb 100644
--- a/libsecret/mock/hkdf.py
+++ b/libsecret/mock/hkdf.py
@@ -18,8 +18,6 @@
 #      system libcryptopp.
 
 import hashlib, hmac
-import math
-from binascii import a2b_hex, b2a_hex
 
 class HKDF(object):
     def __init__(self, ikm, L, salt=None, info=None, digestmod = None):
@@ -50,19 +48,9 @@ class HKDF(object):
 
     #expand PRK
     def expand(self):
-        N = math.ceil(float(self.keylen)/self.hashlen)
         T = b""
         temp = b""
         i=0x01
-        '''while len(T)<2*self.keylen :
-            msg = temp
-            msg += self.info
-            msg += b2a_hex(chr(i))
-            h = hmac.new(self.prk, a2b_hex(msg), self.digest_cons)
-            temp = b2a_hex(h.digest())
-            i += 1
-            T += temp
-       '''
         while len(T)<self.keylen :
             msg = temp
             msg += self.info
@@ -80,5 +68,5 @@ def new(ikm, L, salt=None, info="", digestmod = None):
 
 def hkdf(ikm, length, salt=None, info=""):
        hk = HKDF(ikm, length ,salt,info)
-       computedprk = hk.extract()
+       hk.extract()
        return hk.expand()
\ No newline at end of file
diff --git a/libsecret/mock/service.py b/libsecret/mock/service.py
index 014893a..5fe6706 100644
--- a/libsecret/mock/service.py
+++ b/libsecret/mock/service.py
@@ -15,7 +15,6 @@ import getopt
 import os
 import sys
 import time
-import unittest
 
 from mock import aes, dh, hkdf
 


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