Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Opus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
Opus
Commits
5c3cc556
Commit
5c3cc556
authored
3 years ago
by
Timothy B. Terriberry
Committed by
Jean-Marc Valin
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Minor fixes to kiss99
parent
3a475485
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dnn/kiss99.c
+15
-2
15 additions, 2 deletions
dnn/kiss99.c
dnn/kiss99.h
+4
-0
4 additions, 0 deletions
dnn/kiss99.h
with
19 additions
and
2 deletions
dnn/kiss99.c
+
15
−
2
View file @
5c3cc556
...
...
@@ -45,6 +45,15 @@ void kiss99_srand(kiss99_ctx *_this,const unsigned char *_data,int _ndata){
if
(
i
-
3
<
_ndata
)
_this
->
z
^=
_data
[
i
-
3
];
if
(
i
-
2
<
_ndata
)
_this
->
w
^=
_data
[
i
-
2
];
if
(
i
-
1
<
_ndata
)
_this
->
jsr
^=
_data
[
i
-
1
];
/*Fix any potential short cycles that show up.
These are not too likely, given the way we initialize the state, but they
are technically possible, so let us go ahead and eliminate that
possibility.
See Gregory G. Rose: "KISS: A Bit Too Simple", Cryptographic Communications
No. 10, pp. 123---137, 2018.*/
if
(
_this
->
z
==
0
||
_this
->
z
==
0x9068FFFF
)
_this
->
z
++
;
if
(
_this
->
w
==
0
||
_this
->
w
==
0x464FFFFF
)
_this
->
w
++
;
if
(
_this
->
jsr
==
0
)
_this
->
jsr
++
;
}
uint32_t
kiss99_rand
(
kiss99_ctx
*
_this
){
...
...
@@ -56,8 +65,12 @@ uint32_t kiss99_rand(kiss99_ctx *_this){
znew
=
36969
*
(
_this
->
z
&
0xFFFF
)
+
(
_this
->
z
>>
16
);
wnew
=
18000
*
(
_this
->
w
&
0xFFFF
)
+
(
_this
->
w
>>
16
);
mwc
=
(
znew
<<
16
)
+
wnew
;
shr3
=
_this
->
jsr
^
(
_this
->
jsr
<<
17
);
shr3
^=
shr3
>>
13
;
/*We swap the 13 and 17 from the original 1999 algorithm to produce a single
cycle of maximal length, matching KISS11.
We are not actually using KISS11 because of the impractically large (16 MB)
internal state of the full algorithm.*/
shr3
=
_this
->
jsr
^
(
_this
->
jsr
<<
13
);
shr3
^=
shr3
>>
17
;
shr3
^=
shr3
<<
5
;
cong
=
69069
*
_this
->
jcong
+
1234567
;
_this
->
z
=
znew
;
...
...
This diff is collapsed.
Click to expand it.
dnn/kiss99.h
+
4
−
0
View file @
5c3cc556
...
...
@@ -27,6 +27,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
# define _kiss99_H (1)
# include <stdint.h>
/*KISS PRNG from George Marsaglia (1999 version).
See https://en.wikipedia.org/wiki/KISS_(algorithm) for details.
This is suitable for simulations, but not for use in crytographic contexts.*/
typedef
struct
kiss99_ctx
kiss99_ctx
;
struct
kiss99_ctx
{
...
...
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