ezPyCrypto keys

Discussion in 'Python' started by John Hunter, Aug 27, 2003.

  1. John Hunter

    John Hunter Guest

    I have been playing around with ezPyCrypto. I generated and printed a
    key with

    >>> import ezPyCrypto
    >>> k = ezPyCrypto.key(2048)
    >>> print k.exportKey()


    I noticed there were a lot of N's and M's, too many to occur by chance

    s=k.exportKeyPrivate()
    >>> s.count('N')/float(len(s))

    0.09788189987163029
    >>> s.count('M')/float(len(s))

    0.11

    I quit python and restarted it and generated a new key and found the
    same thing. Ditto when I exported the private key. I also found the
    keys generated in the two sessions to be quite similar (35% characters
    at a given position identical).

    What's going on? Is it abnormal for so many of the characters in the
    exported string to be the same? The machine I am running on is a
    server that rarely has anyone logged in directly. Is this a problem
    with not enough randomness in /dev/random?

    Thanks for any suggestions,
    John Hunter

    ezPyCrypto-0.1.1
    pycrypto-1.9a6
    python2.2
    mother:/var/tmp/ezPyCrypto-0.1.1> uname -a
    Linux mother.paradise.lost 2.4.9 #7 Fri Oct 12 15:20:49 CDT 2001 i686
    unknown
    John Hunter, Aug 27, 2003
    #1
    1. Advertising

  2. John Hunter

    Robert Kern Guest

    In article <>,
    John Hunter <> writes:

    [snip]

    > What's going on? Is it abnormal for so many of the characters in the
    > exported string to be the same? The machine I am running on is a
    > server that rarely has anyone logged in directly. Is this a problem
    > with not enough randomness in /dev/random?


    As Heiko suggests, it's just the serialization protocol that is creating
    this effect. ezPyCrypto keeps the key as a Python long, pickles it along
    with other information, then base64-encodes the resulting string. The
    pickled representation of a long doesn't contain the raw bytes; it
    contains the string representation, so the pickle contains a lot of
    decimal digits rather than a full 0-255 range of bytes. Naturally, this
    representation has redundancy which is made more apparent by the
    base64-encoding.

    All 2048 bits of entropy should still be there.

    > Thanks for any suggestions,
    > John Hunter


    --
    Robert Kern


    "In the fields of hell where the grass grows high
    Are the graves of dreams allowed to die."
    -- Richard Harter
    Robert Kern, Aug 27, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sandeep Kanwal

    serial keys/validation keys

    sandeep Kanwal, Oct 29, 2004, in forum: C++
    Replies:
    1
    Views:
    583
    Mike Wahler
    Oct 29, 2004
  2. Bill Seitz

    ezPyCrypto support AES?

    Bill Seitz, Sep 20, 2004, in forum: Python
    Replies:
    0
    Views:
    370
    Bill Seitz
    Sep 20, 2004
  3. scott

    ezPyCrypto confusion

    scott, May 11, 2005, in forum: Python
    Replies:
    0
    Views:
    355
    scott
    May 11, 2005
  4. ezPyCrypto

    , Sep 14, 2005, in forum: Python
    Replies:
    3
    Views:
    501
    Maciej Dziardziel
    Sep 14, 2005
  5. Harry George
    Replies:
    9
    Views:
    702
    sonal
    Jun 13, 2006
Loading...

Share This Page