OCB-AES implementation in pure Python

Experimental implementation of OCB authentication-encryption mode using AES in pure Python.

This code is experimental and may have bugs, even though it passes all test vectors. Example interface:

        >>> aes = AES(128)
        >>> ocb = OCB(aes)
        >>> nonce = range(16)         # AES block size
        >>> key = [0] * (128/8)       # AES keysize used here
        >>> plaintext = range(10)      # arbitrary length plaintext for encryption
        >>> header = [1] * 5          # arbitrary length "header" plaintext
        >>> ocb.setNonce(nonce)       # nonce MUST NOT be used more than once
        >>> ocb.setKey(key)           # AES key for encryption
        >>> (tag,ciphertext) = ocb.encrypt(plaintext, header)
        
        ciphertext is same length as plaintext
        header remains unencrypted
        tag is 16 bytes long message authentication code (not secret)
        
        >>> print tag, ciphertext
        [112, 241, 108, 123, 21, 7, 119, 43, 239, 210, 156, 158, 111, 17, 42, 46] [180, 107, 115, 96, 69, 33, 217, 56, 249, 65]
        >>> (is_authentic, plaintext2) = ocb.decrypt(header, ciphertext, tag)
        
        is_authentic is True if ciphertext matches "tag" and is authentic
        otherwise plaintext is empty
        
        >>> print is_authentic, plaintext2
        True [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

More information on OCB:

http://www.cs.ucdavis.edu/~rogaway/ocb/

Download:

http://ipsec.pl/files/ipsec/pyocb_0.zip


Odpowiedzi

Dodaj nową odpowiedź

Zawartość tego pola nie będzie udostępniana publicznie. If you have a Gravatar account, used to display your avatar.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <b> <i> <table> <tr> <td> <th> <pre> <blockquote>
  • LaTex commands embedded in text will be interpreted and rendered. Additional information can be found at DruTex Documentation Pages
    • Line and paragraphs break automatically.
    • Assists automatic numbering of tex, equation, and equations environments.
    • Provides different environments to create rendered images (especially maths).
    • Znaki końca linii i akapitu dodawane są automatycznie.
    • Adresy internetowe są automatycznie zamieniane w klikalne odnośniki.
    • E-Mail addresses are hidden with reCAPTCHA Mailhide.

    Więcej informacji na temat formatowania

    CAPTCHA
    Poniższy test chroni przed automatami spammerskimi.