Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jos-tinyssh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mipt-jos
jos-tinyssh
Commits
7bbbeba0
Unverified
Commit
7bbbeba0
authored
4 years ago
by
Jan Mojžíš
Browse files
Options
Downloads
Patches
Plain Diff
crypto-tests/crypto_sort_uint32test.c add
parent
f55ddad2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
crypto-tests/crypto_sort_uint32test.c
+59
-1
59 additions, 1 deletion
crypto-tests/crypto_sort_uint32test.c
with
59 additions
and
1 deletion
crypto-tests/crypto_sort_uint32test.c
+
59
−
1
View file @
7bbbeba0
#include
<unistd.h>
#include
"misc.h"
#include
"crypto_uint32.h"
#include
"crypto_sort_uint32.h"
static
void
test_321
(
void
)
{
crypto_uint32
x
[
3
]
=
{
3
,
2
,
1
};
crypto_sort_uint32
(
x
,
3
);
if
(
x
[
0
]
!=
1
)
fail
(
"crypto_sort_uint32() failure"
);
if
(
x
[
1
]
!=
2
)
fail
(
"crypto_sort_uint32() failure"
);
if
(
x
[
2
]
!=
3
)
fail
(
"crypto_sort_uint32() failure"
);
}
static
void
test_i
(
void
)
{
crypto_uint32
x
[
5
]
=
{
(
crypto_uint32
)
-
1
,
(
crypto_uint32
)
-
2
,
2
,
1
,
0
};
crypto_sort_uint32
(
x
,
5
);
if
(
x
[
0
]
!=
0
)
fail
(
"crypto_sort_uint32() failure"
);
if
(
x
[
1
]
!=
1
)
fail
(
"crypto_sort_uint32() failure"
);
if
(
x
[
2
]
!=
2
)
fail
(
"crypto_sort_uint32() failure"
);
if
(
x
[
3
]
!=
(
crypto_uint32
)
-
2
)
fail
(
"crypto_sort_uint32() failure"
);
if
(
x
[
4
]
!=
(
crypto_uint32
)
-
1
)
fail
(
"crypto_sort_uint32() failure"
);
}
#define SPACESIZE 123
static
crypto_uint32
space
[
SPACESIZE
+
4
];
static
crypto_uint32
buf
[
SPACESIZE
+
4
];
static
unsigned
char
test_pseudorandom_checksum
[
32
]
=
{
0xb6
,
0x48
,
0x52
,
0x41
,
0xd0
,
0x19
,
0xa7
,
0x8c
,
0x61
,
0x4d
,
0x29
,
0x9d
,
0x1f
,
0xda
,
0xb9
,
0xc5
,
0xbd
,
0x47
,
0xe6
,
0x7f
,
0xc2
,
0xf3
,
0x2e
,
0xfd
,
0x32
,
0x21
,
0x7a
,
0x7b
,
0xbb
,
0xec
,
0x02
,
0x08
};
static
void
test_pseudorandom
(
void
)
{
long
long
i
,
j
;
checksum_zero
();
i
=
0
;
for
(
j
=
0
;
j
<
SPACESIZE
;
j
+=
1
+
j
/
4
)
{
pseudorandombytes
(
space
+
i
,
sizeof
(
crypto_uint32
)
*
j
);
crypto_sort_uint32
(
space
+
i
,
j
);
checksum
(
space
+
i
,
sizeof
(
crypto_uint32
)
*
j
);
++
i
;
i
%=
4
;
}
fail_whenbadchecksum
(
test_pseudorandom_checksum
);
}
int
main
(
void
)
{
test_321
();
test_i
();
test_pseudorandom
();
_exit
(
0
);
}
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