コード例 #1
0
ファイル: posix.py プロジェクト: bizonix/DropBoxLibrarySRC
 def __init__(self, devname = None):
     if devname is None:
         self.name = '/dev/urandom'
     else:
         self.name = devname
     f = open(self.name, 'rb', 0)
     fmode = os.fstat(f.fileno())[stat.ST_MODE]
     if not stat.S_ISCHR(fmode):
         f.close()
         raise TypeError('%r is not a character special device' % (self.name,))
     self.__file = f
     BaseRNG.__init__(self)
コード例 #2
0
 def __init__(self, devname=None):
     if devname is None:
         self.name = '/dev/urandom'
     else:
         self.name = devname
     f = open(self.name, 'rb', 0)
     fmode = os.fstat(f.fileno())[stat.ST_MODE]
     if not stat.S_ISCHR(fmode):
         f.close()
         raise TypeError('%r is not a character special device' %
                         (self.name, ))
     self.__file = f
     BaseRNG.__init__(self)
     return
コード例 #3
0
ファイル: posix.py プロジェクト: jkolokotronis/ds_mod_tools
    def __init__(self, devname=None):
        if devname is None:
            self.name = "/dev/urandom"
        else:
            self.name = devname

        # Test that /dev/urandom is a character special device
        f = open(self.name, "rb", 0)
        fmode = os.fstat(f.fileno())[stat.ST_MODE]
        if not stat.S_ISCHR(fmode):
            f.close()
            raise TypeError("%r is not a character special device" % (self.name,))

        self.__file = f

        BaseRNG.__init__(self)
コード例 #4
0
ファイル: posix.py プロジェクト: nessvm/eVoting
    def __init__(self, devname=None):
        if devname is None:
            self.name = "/dev/urandom"
        else:
            self.name = devname

        # Test that /dev/urandom is a character special device
        f = open(self.name, "rb", 0)
        fmode = os.fstat(f.fileno())[stat.ST_MODE]
        if not stat.S_ISCHR(fmode):
            f.close()
            raise TypeError("%r is not a character special device" % (self.name,))

        self.__file = f

        BaseRNG.__init__(self)
コード例 #5
0
ファイル: nt.py プロジェクト: gowhd20/Family-Shopping-Cart
    def flush(self):
        """Work around weakness in Windows RNG.

        The CryptGenRandom mechanism in some versions of Windows allows an
        attacker to learn 128 KiB of past and future output.  As a workaround,
        this function reads 128 KiB of 'random' data from Windows and discards
        it.

        For more information about the weaknesses in CryptGenRandom, see
        _Cryptanalysis of the Random Number Generator of the Windows Operating
        System_, by Leo Dorrendorf and Zvi Gutterman and Benny Pinkas
        http://eprint.iacr.org/2007/419
        """
        if self.closed:
            raise ValueError("I/O operation on closed file")
        data = self.__winrand.get_bytes(128*1024)
        assert (len(data) == 128*1024)
        BaseRNG.flush(self)
コード例 #6
0
ファイル: nt.py プロジェクト: 309972460/software
    def flush(self):
        """Work around weakness in Windows RNG.

        The CryptGenRandom mechanism in some versions of Windows allows an
        attacker to learn 128 KiB of past and future output.  As a workaround,
        this function reads 128 KiB of 'random' data from Windows and discards
        it.

        For more information about the weaknesses in CryptGenRandom, see
        _Cryptanalysis of the Random Number Generator of the Windows Operating
        System_, by Leo Dorrendorf and Zvi Gutterman and Benny Pinkas
        http://eprint.iacr.org/2007/419
        """
        if self.closed:
            raise ValueError("I/O operation on closed file")
        data = self.__winrand.get_bytes(128 * 1024)
        assert (len(data) == 128 * 1024)
        BaseRNG.flush(self)
コード例 #7
0
ファイル: fallback.py プロジェクト: 0xPr0xy/SSHWorm
 def __init__(self):
     self._read = os.urandom
     BaseRNG.__init__(self)
コード例 #8
0
ファイル: nt.py プロジェクト: gowhd20/Family-Shopping-Cart
 def __init__(self):
     self.__winrand = winrandom.new()
     BaseRNG.__init__(self)
コード例 #9
0
 def __init__(self):
     self._read = os.urandom
     BaseRNG.__init__(self)
コード例 #10
0
ファイル: nt.py プロジェクト: 309972460/software
 def __init__(self):
     self.__winrand = winrandom.new()
     BaseRNG.__init__(self)
コード例 #11
0
 def flush(self):
     if self.closed:
         raise ValueError('I/O operation on closed file')
     data = self.__winrand.get_bytes(131072)
     BaseRNG.flush(self)
コード例 #12
0
ファイル: nt.py プロジェクト: bizonix/DropBoxLibrarySRC
 def flush(self):
     if self.closed:
         raise ValueError('I/O operation on closed file')
     data = self.__winrand.get_bytes(131072)
     assert len(data) == 131072
     BaseRNG.flush(self)