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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nettle
nettle
Commits
dca9abf1
Commit
dca9abf1
authored
Jan 20, 2014
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
poly1305_digest: Use union nettle_block16.
parent
efdf4f4b
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
ChangeLog
+5
-0
5 additions, 0 deletions
ChangeLog
poly1305-aes.c
+6
-5
6 additions, 5 deletions
poly1305-aes.c
poly1305-internal.c
+11
-10
11 additions, 10 deletions
poly1305-internal.c
poly1305.h
+2
-2
2 additions, 2 deletions
poly1305.h
with
24 additions
and
17 deletions
ChangeLog
+
5
−
0
View file @
dca9abf1
2014-01-20 Niels Möller <nisse@lysator.liu.se>
2014-01-20 Niels Möller <nisse@lysator.liu.se>
* poly1305-internal.c (poly1305_digest): Use union nettle_block16
for s argument.
* poly1305-aes.c (poly1305_aes_digest): Update for poly1305_digest
change.
Merged poly1305 changes (starting at 2013-11-08).
Merged poly1305 changes (starting at 2013-11-08).
* x86_64/poly1305-internal.asm: Update to new interface.
* x86_64/poly1305-internal.asm: Update to new interface.
poly1305_digest much simplified.
poly1305_digest much simplified.
...
...
This diff is collapsed.
Click to expand it.
poly1305-aes.c
+
6
−
5
View file @
dca9abf1
...
@@ -47,7 +47,8 @@ poly1305_aes_set_nonce (struct poly1305_aes_ctx *ctx,
...
@@ -47,7 +47,8 @@ poly1305_aes_set_nonce (struct poly1305_aes_ctx *ctx,
#define COMPRESS(ctx, data) _poly1305_block(&(ctx)->pctx, (data), 1)
#define COMPRESS(ctx, data) _poly1305_block(&(ctx)->pctx, (data), 1)
void
void
poly1305_aes_update
(
struct
poly1305_aes_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
data
)
poly1305_aes_update
(
struct
poly1305_aes_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
data
)
{
{
MD_UPDATE
(
ctx
,
length
,
data
,
COMPRESS
,
(
void
)
0
);
MD_UPDATE
(
ctx
,
length
,
data
,
COMPRESS
,
(
void
)
0
);
}
}
...
@@ -56,7 +57,7 @@ void
...
@@ -56,7 +57,7 @@ void
poly1305_aes_digest
(
struct
poly1305_aes_ctx
*
ctx
,
poly1305_aes_digest
(
struct
poly1305_aes_ctx
*
ctx
,
size_t
length
,
uint8_t
*
digest
)
size_t
length
,
uint8_t
*
digest
)
{
{
u
int8_t
s
[
POLY1305_BLOCK_SIZE
]
;
u
nion
nettle_block16
s
;
/* final bytes */
/* final bytes */
if
(
ctx
->
index
>
0
)
if
(
ctx
->
index
>
0
)
{
{
...
@@ -68,10 +69,10 @@ poly1305_aes_digest (struct poly1305_aes_ctx *ctx,
...
@@ -68,10 +69,10 @@ poly1305_aes_digest (struct poly1305_aes_ctx *ctx,
_poly1305_block
(
&
ctx
->
pctx
,
ctx
->
block
,
0
);
_poly1305_block
(
&
ctx
->
pctx
,
ctx
->
block
,
0
);
}
}
aes128_encrypt
(
&
ctx
->
aes
,
POLY1305_BLOCK_SIZE
,
s
,
ctx
->
nonce
);
aes128_encrypt
(
&
ctx
->
aes
,
POLY1305_BLOCK_SIZE
,
s
.
b
,
ctx
->
nonce
);
poly1305_digest
(
&
ctx
->
pctx
,
s
);
poly1305_digest
(
&
ctx
->
pctx
,
&
s
);
memcpy
(
digest
,
s
,
length
);
memcpy
(
digest
,
s
.
b
,
length
);
INCREMENT
(
16
,
ctx
->
nonce
);
INCREMENT
(
16
,
ctx
->
nonce
);
ctx
->
index
=
0
;
ctx
->
index
=
0
;
...
...
This diff is collapsed.
Click to expand it.
poly1305-internal.c
+
11
−
10
View file @
dca9abf1
...
@@ -86,7 +86,7 @@ poly1305_set_key(struct poly1305_ctx *ctx, const uint8_t key[16])
...
@@ -86,7 +86,7 @@ poly1305_set_key(struct poly1305_ctx *ctx, const uint8_t key[16])
}
}
void
void
_poly1305_block
(
struct
poly1305_ctx
*
ctx
,
const
uint8_t
m
[
16
]
,
unsigned
t4
)
_poly1305_block
(
struct
poly1305_ctx
*
ctx
,
const
uint8_t
*
m
,
unsigned
t4
)
{
{
uint32_t
t0
,
t1
,
t2
,
t3
;
uint32_t
t0
,
t1
,
t2
,
t3
;
uint32_t
b
;
uint32_t
b
;
...
@@ -121,7 +121,7 @@ _poly1305_block (struct poly1305_ctx *ctx, const uint8_t m[16], unsigned t4)
...
@@ -121,7 +121,7 @@ _poly1305_block (struct poly1305_ctx *ctx, const uint8_t m[16], unsigned t4)
/* Adds digest to the nonce */
/* Adds digest to the nonce */
void
void
poly1305_digest
(
struct
poly1305_ctx
*
ctx
,
u
int8_t
*
s
)
poly1305_digest
(
struct
poly1305_ctx
*
ctx
,
u
nion
nettle_block16
*
s
)
{
{
uint32_t
b
,
nb
;
uint32_t
b
,
nb
;
uint64_t
f0
,
f1
,
f2
,
f3
;
uint64_t
f0
,
f1
,
f2
,
f3
;
...
@@ -149,18 +149,19 @@ poly1305_digest (struct poly1305_ctx *ctx, uint8_t *s)
...
@@ -149,18 +149,19 @@ poly1305_digest (struct poly1305_ctx *ctx, uint8_t *s)
ctx
->
h3
=
(
ctx
->
h3
&
nb
)
|
(
g3
&
b
);
ctx
->
h3
=
(
ctx
->
h3
&
nb
)
|
(
g3
&
b
);
ctx
->
h4
=
(
ctx
->
h4
&
nb
)
|
(
g4
&
b
);
ctx
->
h4
=
(
ctx
->
h4
&
nb
)
|
(
g4
&
b
);
f0
=
((
ctx
->
h0
)
|
(
ctx
->
h1
<<
26
))
+
(
uint64_t
)
LE_READ_UINT32
(
s
);
/* FIXME: Take advantage of s being aligned as an unsigned long. */
f1
=
((
ctx
->
h1
>>
6
)
|
(
ctx
->
h2
<<
20
))
+
(
uint64_t
)
LE_READ_UINT32
(
s
+
4
);
f0
=
((
ctx
->
h0
)
|
(
ctx
->
h1
<<
26
))
+
(
uint64_t
)
LE_READ_UINT32
(
s
->
b
);
f2
=
((
ctx
->
h2
>>
12
)
|
(
ctx
->
h3
<<
14
))
+
(
uint64_t
)
LE_READ_UINT32
(
s
+
8
);
f1
=
((
ctx
->
h1
>>
6
)
|
(
ctx
->
h2
<<
20
))
+
(
uint64_t
)
LE_READ_UINT32
(
s
->
b
+
4
);
f3
=
((
ctx
->
h3
>>
18
)
|
(
ctx
->
h4
<<
8
))
+
(
uint64_t
)
LE_READ_UINT32
(
s
+
12
);
f2
=
((
ctx
->
h2
>>
12
)
|
(
ctx
->
h3
<<
14
))
+
(
uint64_t
)
LE_READ_UINT32
(
s
->
b
+
8
);
f3
=
((
ctx
->
h3
>>
18
)
|
(
ctx
->
h4
<<
8
))
+
(
uint64_t
)
LE_READ_UINT32
(
s
->
b
+
12
);
LE_WRITE_UINT32
(
s
,
f0
);
LE_WRITE_UINT32
(
s
->
b
,
f0
);
f1
+=
(
f0
>>
32
);
f1
+=
(
f0
>>
32
);
LE_WRITE_UINT32
(
s
+
4
,
f1
);
LE_WRITE_UINT32
(
s
->
b
+
4
,
f1
);
f2
+=
(
f1
>>
32
);
f2
+=
(
f1
>>
32
);
LE_WRITE_UINT32
(
s
+
8
,
f2
);
LE_WRITE_UINT32
(
s
->
b
+
8
,
f2
);
f3
+=
(
f2
>>
32
);
f3
+=
(
f2
>>
32
);
LE_WRITE_UINT32
(
s
+
12
,
f3
);
LE_WRITE_UINT32
(
s
->
b
+
12
,
f3
);
ctx
->
h0
=
0
;
ctx
->
h0
=
0
;
ctx
->
h1
=
0
;
ctx
->
h1
=
0
;
...
...
This diff is collapsed.
Click to expand it.
poly1305.h
+
2
−
2
View file @
dca9abf1
...
@@ -71,9 +71,9 @@ struct poly1305_ctx {
...
@@ -71,9 +71,9 @@ struct poly1305_ctx {
/* Low-level internal interface. */
/* Low-level internal interface. */
void
poly1305_set_key
(
struct
poly1305_ctx
*
ctx
,
const
uint8_t
key
[
POLY1305_KEY_SIZE
]);
void
poly1305_set_key
(
struct
poly1305_ctx
*
ctx
,
const
uint8_t
key
[
POLY1305_KEY_SIZE
]);
/* Extracts digest, and adds it to s, the encrypted nonce. */
/* Extracts digest, and adds it to s, the encrypted nonce. */
void
poly1305_digest
(
struct
poly1305_ctx
*
ctx
,
u
int8_t
*
s
);
void
poly1305_digest
(
struct
poly1305_ctx
*
ctx
,
u
nion
nettle_block16
*
s
);
/* Internal function. Process one block. */
/* Internal function. Process one block. */
void
_poly1305_block
(
struct
poly1305_ctx
*
ctx
,
const
uint8_t
m
[
POLY1305_BLOCK_SIZE
]
,
void
_poly1305_block
(
struct
poly1305_ctx
*
ctx
,
const
uint8_t
*
m
,
unsigned
high
);
unsigned
high
);
/* poly1305-aes */
/* poly1305-aes */
...
...
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