Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wim Lewis
nettle
Commits
61d9a6a0
Commit
61d9a6a0
authored
11 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
New type nettle_block16.
parent
5ea9dfb0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
ChangeLog
+7
-0
7 additions, 0 deletions
ChangeLog
gcm.c
+15
-14
15 additions, 14 deletions
gcm.c
gcm.h
+4
-11
4 additions, 11 deletions
gcm.h
nettle-types.h
+7
-0
7 additions, 0 deletions
nettle-types.h
with
33 additions
and
25 deletions
ChangeLog
+
7
−
0
View file @
61d9a6a0
2014-01-13 Niels Möller <nisse@lysator.liu.se>
* nettle-types.h (union nettle_block16): New type, replacing union
gcm_block.
* gcm.h (union gcm_block): Deleted. Replaced by nettle_block16.
* gcm.c: Replaced all use of gcm_block by nettle_block16.
2014-01-04 Niels Möller <nisse@lysator.liu.se>
* config.guess: Updated to 2014-01-01 version, from
...
...
This diff is collapsed.
Click to expand it.
gcm.c
+
15
−
14
View file @
61d9a6a0
...
...
@@ -50,7 +50,8 @@
#define GHASH_POLYNOMIAL 0xE1UL
static
void
gcm_gf_add
(
union
gcm_block
*
r
,
const
union
gcm_block
*
x
,
const
union
gcm_block
*
y
)
gcm_gf_add
(
union
nettle_block16
*
r
,
const
union
nettle_block16
*
x
,
const
union
nettle_block16
*
y
)
{
r
->
w
[
0
]
=
x
->
w
[
0
]
^
y
->
w
[
0
];
r
->
w
[
1
]
=
x
->
w
[
1
]
^
y
->
w
[
1
];
...
...
@@ -63,7 +64,7 @@ gcm_gf_add (union gcm_block *r, const union gcm_block *x, const union gcm_block
shifted out is one, the defining polynomial is added to cancel it
out. r == x is allowed. */
static
void
gcm_gf_shift
(
union
gcm
_block
*
r
,
const
union
gcm
_block
*
x
)
gcm_gf_shift
(
union
nettle
_block
16
*
r
,
const
union
nettle
_block
16
*
x
)
{
long
mask
;
...
...
@@ -111,10 +112,10 @@ gcm_gf_shift (union gcm_block *r, const union gcm_block *x)
specification. y may be shorter than a full block, missing bytes
are assumed zero. */
static
void
gcm_gf_mul
(
union
gcm
_block
*
x
,
const
union
gcm
_block
*
y
)
gcm_gf_mul
(
union
nettle
_block
16
*
x
,
const
union
nettle
_block
16
*
y
)
{
union
gcm
_block
V
;
union
gcm
_block
Z
;
union
nettle
_block
16
V
;
union
nettle
_block
16
Z
;
unsigned
i
;
memcpy
(
V
.
b
,
x
,
sizeof
(
V
));
...
...
@@ -150,7 +151,7 @@ shift_table[0x10] = {
};
static
void
gcm_gf_shift_4
(
union
gcm
_block
*
x
)
gcm_gf_shift_4
(
union
nettle
_block
16
*
x
)
{
unsigned
long
*
w
=
x
->
w
;
unsigned
long
reduce
;
...
...
@@ -195,9 +196,9 @@ gcm_gf_shift_4(union gcm_block *x)
}
static
void
gcm_gf_mul
(
union
gcm
_block
*
x
,
const
union
gcm
_block
*
table
)
gcm_gf_mul
(
union
nettle
_block
16
*
x
,
const
union
nettle
_block
16
*
table
)
{
union
gcm
_block
Z
;
union
nettle
_block
16
Z
;
unsigned
i
;
memset
(
Z
.
b
,
0
,
sizeof
(
Z
));
...
...
@@ -218,7 +219,7 @@ gcm_gf_mul (union gcm_block *x, const union gcm_block *table)
#define gcm_hash _nettle_gcm_hash8
void
_nettle_gcm_hash8
(
const
struct
gcm_key
*
key
,
union
gcm
_block
*
x
,
_nettle_gcm_hash8
(
const
struct
gcm_key
*
key
,
union
nettle
_block
16
*
x
,
size_t
length
,
const
uint8_t
*
data
);
# else
/* !HAVE_NATIVE_gcm_hash8 */
static
const
uint16_t
...
...
@@ -258,7 +259,7 @@ shift_table[0x100] = {
};
static
void
gcm_gf_shift_8
(
union
gcm
_block
*
x
)
gcm_gf_shift_8
(
union
nettle
_block
16
*
x
)
{
unsigned
long
*
w
=
x
->
w
;
unsigned
long
reduce
;
...
...
@@ -296,9 +297,9 @@ gcm_gf_shift_8(union gcm_block *x)
}
static
void
gcm_gf_mul
(
union
gcm
_block
*
x
,
const
union
gcm
_block
*
table
)
gcm_gf_mul
(
union
nettle
_block
16
*
x
,
const
union
nettle
_block
16
*
table
)
{
union
gcm
_block
Z
;
union
nettle
_block
16
Z
;
unsigned
i
;
memcpy
(
Z
.
b
,
table
[
x
->
b
[
GCM_BLOCK_SIZE
-
1
]].
b
,
GCM_BLOCK_SIZE
);
...
...
@@ -356,7 +357,7 @@ gcm_set_key(struct gcm_key *key,
#ifndef gcm_hash
static
void
gcm_hash
(
const
struct
gcm_key
*
key
,
union
gcm
_block
*
x
,
gcm_hash
(
const
struct
gcm_key
*
key
,
union
nettle
_block
16
*
x
,
size_t
length
,
const
uint8_t
*
data
)
{
for
(;
length
>=
GCM_BLOCK_SIZE
;
...
...
@@ -374,7 +375,7 @@ gcm_hash(const struct gcm_key *key, union gcm_block *x,
#endif
/* !gcm_hash */
static
void
gcm_hash_sizes
(
const
struct
gcm_key
*
key
,
union
gcm
_block
*
x
,
gcm_hash_sizes
(
const
struct
gcm_key
*
key
,
union
nettle
_block
16
*
x
,
uint64_t
auth_size
,
uint64_t
data_size
)
{
uint8_t
buffer
[
GCM_BLOCK_SIZE
];
...
...
This diff is collapsed.
Click to expand it.
gcm.h
+
4
−
11
View file @
61d9a6a0
...
...
@@ -60,27 +60,20 @@ extern "C" {
#define GCM_TABLE_BITS 8
/* To make sure that we have proper alignment. */
union
gcm_block
{
uint8_t
b
[
GCM_BLOCK_SIZE
];
unsigned
long
w
[
GCM_BLOCK_SIZE
/
sizeof
(
unsigned
long
)];
};
/* Hashing subkey */
struct
gcm_key
{
union
gcm
_block
h
[
1
<<
GCM_TABLE_BITS
];
union
nettle
_block
16
h
[
1
<<
GCM_TABLE_BITS
];
};
/* Per-message state, depending on the iv */
struct
gcm_ctx
{
/* Original counter block */
union
gcm
_block
iv
;
union
nettle
_block
16
iv
;
/* Updated for each block. */
union
gcm
_block
ctr
;
union
nettle
_block
16
ctr
;
/* Hashing state */
union
gcm
_block
x
;
union
nettle
_block
16
x
;
uint64_t
auth_size
;
uint64_t
data_size
;
};
...
...
This diff is collapsed.
Click to expand it.
nettle-types.h
+
7
−
0
View file @
61d9a6a0
...
...
@@ -34,6 +34,13 @@
extern
"C"
{
#endif
/* An aligned 16-byte block. */
union
nettle_block16
{
uint8_t
b
[
16
];
unsigned
long
w
[
16
/
sizeof
(
unsigned
long
)];
};
/* Randomness. Used by key generation and dsa signature creation. */
typedef
void
nettle_random_func
(
void
*
ctx
,
size_t
length
,
uint8_t
*
dst
);
...
...
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