Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
2a35b6b3
Commit
2a35b6b3
authored
11 years ago
by
Donald Stufft
Browse files
Options
Downloads
Patches
Plain Diff
Move the random implementation over to the new layout
parent
a5a57dec
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/nacl/_lib/randombytes.h
+16
-0
16 additions, 0 deletions
src/nacl/_lib/randombytes.h
src/nacl/c/__init__.py
+3
-0
3 additions, 0 deletions
src/nacl/c/__init__.py
src/nacl/c/randombytes.py
+29
-0
29 additions, 0 deletions
src/nacl/c/randombytes.py
src/nacl/utils.py
+2
-4
2 additions, 4 deletions
src/nacl/utils.py
with
50 additions
and
4 deletions
src/nacl/_lib/randombytes.h
0 → 100644
+
16
−
0
View file @
2a35b6b3
/* Copyright 2013 Donald Stufft and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
void
randombytes
(
unsigned
char
*
const
buf
,
const
unsigned
long
long
buf_len
);
This diff is collapsed.
Click to expand it.
src/nacl/c/__init__.py
+
3
−
0
View file @
2a35b6b3
...
@@ -23,6 +23,7 @@ from nacl.c.crypto_scalarmult import (
...
@@ -23,6 +23,7 @@ from nacl.c.crypto_scalarmult import (
crypto_scalarmult_BYTES
,
crypto_scalarmult_SCALARBYTES
,
crypto_scalarmult_BYTES
,
crypto_scalarmult_SCALARBYTES
,
crypto_scalarmult_base
,
crypto_scalarmult_base
,
)
)
from
nacl.c.randombytes
import
randombytes
__all__
=
[
__all__
=
[
...
@@ -42,4 +43,6 @@ __all__ = [
...
@@ -42,4 +43,6 @@ __all__ = [
"
crypto_scalarmult_BYTES
"
,
"
crypto_scalarmult_BYTES
"
,
"
crypto_scalarmult_SCALARBYTES
"
,
"
crypto_scalarmult_SCALARBYTES
"
,
"
crypto_scalarmult_base
"
,
"
crypto_scalarmult_base
"
,
"
randombytes
"
,
]
]
This diff is collapsed.
Click to expand it.
src/nacl/c/randombytes.py
0 → 100644
+
29
−
0
View file @
2a35b6b3
# Copyright 2013 Donald Stufft and individual contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
absolute_import
,
division
,
print_function
from
nacl
import
_lib
as
lib
def
randombytes
(
size
):
"""
Returns ``size`` number of random bytes from a cryptographically secure
random source.
:param size: int
:rtype: bytes
"""
buf
=
lib
.
ffi
.
new
(
"
unsigned char[]
"
,
size
)
lib
.
randombytes
(
buf
,
size
)
return
lib
.
ffi
.
buffer
(
buf
,
size
)[:]
This diff is collapsed.
Click to expand it.
src/nacl/utils.py
+
2
−
4
View file @
2a35b6b3
...
@@ -16,7 +16,7 @@ from __future__ import division
...
@@ -16,7 +16,7 @@ from __future__ import division
import
six
import
six
from
.c
import
_lib
as
nacl
import
nacl
.c
class
EncryptedMessage
(
six
.
binary_type
):
class
EncryptedMessage
(
six
.
binary_type
):
...
@@ -57,6 +57,4 @@ class StringFixer(object):
...
@@ -57,6 +57,4 @@ class StringFixer(object):
def
random
(
size
=
32
):
def
random
(
size
=
32
):
data
=
nacl
.
ffi
.
new
(
"
unsigned char[]
"
,
size
)
return
nacl
.
c
.
randombytes
(
size
)
nacl
.
lib
.
randombytes
(
data
,
size
)
return
nacl
.
ffi
.
buffer
(
data
,
size
)[:]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment