Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(3)  |  Derive(0)  |  Import(1)
Add oaep padding suitable for a 'bytes'-byte key, using 'p' as a
security parameter and 'rng' as a random number generator.

If rng is None, uses the general purpose RNG.  The parameter may
be any length.  len(data) must be <= bytes-42.  

        def _add_oaep_padding(data, p, bytes, rng=None):
    '''Add oaep padding suitable for a 'bytes'-byte key, using 'p' as a
       security parameter and 'rng' as a random number generator.

       If rng is None, uses the general purpose RNG.  The parameter may
       be any length.  len(data) must be <= bytes-42.  '''
    if rng is None:
        rng = getCommonPRNG()
    bytes = bytes-1
    mLen = len(data)
    paddingLen = bytes-mLen-2*DIGEST_LEN-1
    if paddingLen < 0:
        raise CryptoError("Message too long")
    db = "%s%s\x01%s" %(sha1(p),"\x00"*paddingLen,data)
    seed = rng.getBytes(DIGEST_LEN)
    maskedDB = _ml.strxor(db, _oaep_mgf(seed, bytes-DIGEST_LEN))
    maskedSeed = _ml.strxor(seed, _oaep_mgf(maskedDB, DIGEST_LEN))
    return '\x00%s%s'%(maskedSeed, maskedDB)
        


src/m/i/mixminion-HEAD/lib/mixminion/benchmark.py   mixminion(Download)
from mixminion.Crypto import *
from mixminion.Crypto import OAEP_PARAMETER
from mixminion.Crypto import _add_oaep_padding, _check_oaep_padding
from mixminion.Packet import SMTP_TYPE, CompressedDataTooLong, IPV4Info
from mixminion.ServerInfo import ServerInfo
 
    print "OAEP_add (70->128B) (native python)",
    print timeit((lambda c=c: _add_oaep_padding(s70b,OAEP_PARAMETER,128,c)),
                 10000)
    r = _add_oaep_padding(s70b, OAEP_PARAMETER,128,c)

src/m/i/mixminion-HEAD/lib/mixminion/testSupport.py   mixminion(Download)
    print "   original string M:",hexStr(s)
    assert pk1.get_modulus_bytes() == 256
    enc = mixminion.Crypto._add_oaep_padding(s,
                mixminion.Crypto.OAEP_PARAMETER,256,CyclicRNG())
    print "   Padded string (2048 bits):",hexStr(enc)