Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
4ad8217a
Kaydet (Commit)
4ad8217a
authored
Agu 30, 2004
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
win32_urandom(): Rewrite to Python C standards (hard tabs, function name
in first column, no parens around return value).
üst
38330fe5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
posixmodule.c
Modules/posixmodule.c
+21
-14
No files found.
Modules/posixmodule.c
Dosyayı görüntüle @
4ad8217a
...
@@ -7236,15 +7236,16 @@ typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV hProv, DWORD dwLen,\
...
@@ -7236,15 +7236,16 @@ typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV hProv, DWORD dwLen,\
static
CRYPTGENRANDOM
pCryptGenRandom
=
NULL
;
static
CRYPTGENRANDOM
pCryptGenRandom
=
NULL
;
static
HCRYPTPROV
hCryptProv
=
0
;
static
HCRYPTPROV
hCryptProv
=
0
;
static
PyObject
*
win32_urandom
(
PyObject
*
self
,
PyObject
*
args
)
static
PyObject
*
win32_urandom
(
PyObject
*
self
,
PyObject
*
args
)
{
{
int
howMany
=
0
;
int
howMany
=
0
;
unsigned
char
*
bytes
=
NULL
;
unsigned
char
*
bytes
=
NULL
;
PyObject
*
returnVal
=
NULL
;
PyObject
*
returnVal
=
NULL
;
/* Read arguments */
/* Read arguments */
if
(
!
PyArg_ParseTuple
(
args
,
"i"
,
&
howMany
))
if
(
!
PyArg_ParseTuple
(
args
,
"i"
,
&
howMany
))
return
(
NULL
)
;
return
NULL
;
if
(
hCryptProv
==
0
)
{
if
(
hCryptProv
==
0
)
{
HINSTANCE
hAdvAPI32
=
NULL
;
HINSTANCE
hAdvAPI32
=
NULL
;
...
@@ -7252,32 +7253,38 @@ static PyObject* win32_urandom(PyObject *self, PyObject *args)
...
@@ -7252,32 +7253,38 @@ static PyObject* win32_urandom(PyObject *self, PyObject *args)
/* Obtain handle to the DLL containing CryptoAPI
/* Obtain handle to the DLL containing CryptoAPI
This should not fail */
This should not fail */
if
(
(
hAdvAPI32
=
GetModuleHandle
(
"advapi32.dll"
))
==
NULL
)
hAdvAPI32
=
GetModuleHandle
(
"advapi32.dll"
);
if
(
hAdvAPI32
==
NULL
)
return
win32_error
(
"GetModuleHandle"
,
NULL
);
return
win32_error
(
"GetModuleHandle"
,
NULL
);
/* Obtain pointers to the CryptoAPI functions
/* Obtain pointers to the CryptoAPI functions
This will fail on some early versions of Win95 */
This will fail on some early versions of Win95 */
pCryptAcquireContext
=
(
CRYPTACQUIRECONTEXTA
)
GetProcAddress
(
hAdvAPI32
,
\
pCryptAcquireContext
=
(
CRYPTACQUIRECONTEXTA
)
GetProcAddress
(
hAdvAPI32
,
"CryptAcquireContextA"
);
"CryptAcquireContextA"
);
pCryptGenRandom
=
(
CRYPTGENRANDOM
)
GetProcAddress
(
hAdvAPI32
,
\
if
(
pCryptAcquireContext
==
NULL
)
"CryptGenRandom"
);
return
PyErr_Format
(
PyExc_NotImplementedError
,
"CryptAcquireContextA not found"
);
if
(
pCryptAcquireContext
==
NULL
||
pCryptGenRandom
==
NULL
)
return
PyErr_Format
(
PyExc_NotImplementedError
,
\
pCryptGenRandom
=
(
CRYPTGENRANDOM
)
GetProcAddress
(
hAdvAPI32
,
"CryptGenRandom"
);
if
(
pCryptAcquireContext
==
NULL
)
return
PyErr_Format
(
PyExc_NotImplementedError
,
"CryptGenRandom not found"
);
"CryptGenRandom not found"
);
/* Acquire context */
/* Acquire context */
if
(
!
pCryptAcquireContext
(
&
hCryptProv
,
NULL
,
NULL
,
PROV_RSA_F
ULL
,
if
(
!
pCryptAcquireContext
(
&
hCryptProv
,
NULL
,
N
ULL
,
CRYPT_VERIFYCONTEXT
))
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
))
return
win32_error
(
"CryptAcquireContext"
,
NULL
);
return
win32_error
(
"CryptAcquireContext"
,
NULL
);
}
}
/* Allocate bytes */
/* Allocate bytes */
if
((
bytes
=
(
unsigned
char
*
)
PyMem_Malloc
(
howMany
))
==
NULL
)
bytes
=
(
unsigned
char
*
)
PyMem_Malloc
(
howMany
);
if
(
bytes
==
NULL
)
return
PyErr_NoMemory
();
return
PyErr_NoMemory
();
/* Get random data */
/* Get random data */
if
(
!
pCryptGenRandom
(
hCryptProv
,
howMany
,
bytes
))
{
if
(
!
pCryptGenRandom
(
hCryptProv
,
howMany
,
bytes
))
{
PyMem_Free
(
bytes
);
PyMem_Free
(
bytes
);
return
win32_error
(
"CryptGenRandom"
,
NULL
);
return
win32_error
(
"CryptGenRandom"
,
NULL
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment