Beispiel #1
0
 def _nonce_and_mutated_key(self, key):
     # This generates a nonce which may be used as a salt, IV, or
     # counter-prefix depending the algorithm and mode in use. We
     # also use it to derive a mutated key for each message, thus
     # reducing the risks of the (key, iv) pairs ever repeating even
     # if a mistake is made somewhere else.
     nonce = '%32.32x' % getrandbits(32 * 4)
     return nonce, genkey(key, nonce)[:32].strip()
Beispiel #2
0
 def _nonce_and_mutated_key(self, key):
     # This generates a nonce which may be used as a salt, IV, or
     # counter-prefix depending the algorithm and mode in use. We
     # also use it to derive a mutated key for each message, thus
     # reducing the risks of the (key, iv) pairs ever repeating even
     # if a mistake is made somewhere else.
     nonce = '%32.32x' % getrandbits(32 * 4)
     return nonce, genkey(key, nonce)[:32].strip()
Beispiel #3
0
"""
    LEGACY_TEST_2 = """\
-----BEGIN MAILPILE ENCRYPTED DATA-----
cipher: aes-256-cbc
nonce: SB+fmmM72oFpf/FO4wnaHhFBvhgzpbwW
md5sum: 90dfb2850da49c8a6027415521dadb3c

U2FsdGVkX19U8G7SKp8QygUusdHZThlrLcI04+jZ9U5kwfsw7bJJ2721dwgIpCUh
3wpQjsYtFF2dcKBjrG7xyw==

-----END MAILPILE ENCRYPTED DATA-----
"""

    # Do this before checking for fd leaks, as it may open up /dev/urandom
    # and keep it open.
    b = getrandbits(128)

    # Create a pipe, this tells us which FDs are available next
    fdpair1 = os.pipe()
    for fd in fdpair1:
        os.close(fd)
    def fdcheck(where):
        fdpair2 = os.pipe()
        try:
            for fd in fdpair2:
                if fd not in fdpair1:
                    print 'Probably have an FD leak at %s!' % where
                    print 'Verify with: lsof -g %s' % os.getpid()
                    import time
                    time.sleep(900)
                    return False
Beispiel #4
0
"""
    LEGACY_TEST_2 = """\
-----BEGIN MAILPILE ENCRYPTED DATA-----
cipher: aes-256-cbc
nonce: SB+fmmM72oFpf/FO4wnaHhFBvhgzpbwW
md5sum: 90dfb2850da49c8a6027415521dadb3c

U2FsdGVkX19U8G7SKp8QygUusdHZThlrLcI04+jZ9U5kwfsw7bJJ2721dwgIpCUh
3wpQjsYtFF2dcKBjrG7xyw==

-----END MAILPILE ENCRYPTED DATA-----
"""

    # Do this before checking for fd leaks, as it may open up /dev/urandom
    # and keep it open.
    b = getrandbits(128)

    # Create a pipe, this tells us which FDs are available next
    fdpair1 = os.pipe()
    for fd in fdpair1:
        os.close(fd)

    def fdcheck(where):
        fdpair2 = os.pipe()
        try:
            for fd in fdpair2:
                if fd not in fdpair1:
                    print 'Probably have an FD leak at %s!' % where
                    print 'Verify with: lsof -g %s' % os.getpid()
                    import time
                    time.sleep(900)