Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
e05d1ff2
Commit
e05d1ff2
authored
Aug 23, 2016
by
Rusty Russell
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/pr/47'
Closes: 47
parents
87ea330f
c8206733
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
14 deletions
+15
-14
ccan/crypto/sha256/_info
ccan/crypto/sha256/_info
+1
-0
ccan/crypto/sha256/sha256.c
ccan/crypto/sha256/sha256.c
+7
-6
ccan/crypto/sha256/sha256.h
ccan/crypto/sha256/sha256.h
+5
-6
ccan/crypto/sha256/test/run-33-bit-test.c
ccan/crypto/sha256/test/run-33-bit-test.c
+2
-2
No files found.
ccan/crypto/sha256/_info
View file @
e05d1ff2
...
...
@@ -40,6 +40,7 @@ int main(int argc, char *argv[])
return 1;
if (strcmp(argv[1], "depends") == 0) {
printf("ccan/compiler\n");
printf("ccan/endian\n");
return 0;
}
...
...
ccan/crypto/sha256/sha256.c
View file @
e05d1ff2
...
...
@@ -8,6 +8,7 @@
*/
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/endian/endian.h>
#include <ccan/compiler/compiler.h>
#include <stdbool.h>
#include <assert.h>
#include <string.h>
...
...
@@ -17,16 +18,16 @@ static void invalidate_sha256(struct sha256_ctx *ctx)
#ifdef CCAN_CRYPTO_SHA256_USE_OPENSSL
ctx
->
c
.
md_len
=
0
;
#else
ctx
->
bytes
=
-
1ULL
;
ctx
->
bytes
=
(
size_t
)
-
1
;
#endif
}
static
void
check_sha256
(
struct
sha256_ctx
*
ctx
)
static
void
check_sha256
(
struct
sha256_ctx
*
ctx
UNUSED
)
{
#ifdef CCAN_CRYPTO_SHA256_USE_OPENSSL
assert
(
ctx
->
c
.
md_len
!=
0
);
#else
assert
(
ctx
->
bytes
!=
-
1ULL
);
assert
(
ctx
->
bytes
!=
(
size_t
)
-
1
);
#endif
}
...
...
@@ -166,7 +167,7 @@ static void Transform(uint32_t *s, const uint32_t *chunk)
s
[
7
]
+=
h
;
}
static
bool
alignment_ok
(
const
void
*
p
,
size_t
n
)
static
bool
alignment_ok
(
const
void
*
p
UNUSED
,
size_t
n
UNUSED
)
{
#if HAVE_UNALIGNED_ACCESS
return
true
;
...
...
@@ -228,9 +229,9 @@ void sha256_done(struct sha256_ctx *ctx, struct sha256 *res)
uint64_t
sizedesc
;
size_t
i
;
sizedesc
=
cpu_to_be64
(
ctx
->
bytes
<<
3
);
sizedesc
=
cpu_to_be64
(
(
uint64_t
)
ctx
->
bytes
<<
3
);
/* Add '1' bit to terminate, then all 0 bits, up to next block - 8. */
add
(
ctx
,
pad
,
1
+
((
1
19
-
(
ctx
->
bytes
%
64
)
)
%
64
));
add
(
ctx
,
pad
,
1
+
((
1
28
-
8
-
(
ctx
->
bytes
%
64
)
-
1
)
%
64
));
/* Add number of bits of data (big endian) */
add
(
ctx
,
&
sizedesc
,
8
);
for
(
i
=
0
;
i
<
sizeof
(
ctx
->
s
)
/
sizeof
(
ctx
->
s
[
0
]);
i
++
)
...
...
ccan/crypto/sha256/sha256.h
View file @
e05d1ff2
...
...
@@ -21,10 +21,8 @@
*/
struct
sha256
{
union
{
/* Array of chars */
unsigned
char
u8
[
32
];
/* Array of uint32_t */
uint32_t
u32
[
8
];
unsigned
char
u8
[
32
];
}
u
;
};
...
...
@@ -47,11 +45,11 @@ struct sha256_ctx {
SHA256_CTX
c
;
#else
uint32_t
s
[
8
];
uint64_t
bytes
;
union
{
uint32_t
u32
[
8
];
uint32_t
u32
[
16
];
unsigned
char
u8
[
64
];
}
buf
;
size_t
bytes
;
#endif
};
...
...
@@ -106,7 +104,8 @@ void sha256_init(struct sha256_ctx *ctx);
#else
#define SHA256_INIT \
{ { 0x6a09e667ul, 0xbb67ae85ul, 0x3c6ef372ul, 0xa54ff53aul, \
0x510e527ful, 0x9b05688cul, 0x1f83d9abul, 0x5be0cd19ul }, 0 }
0x510e527ful, 0x9b05688cul, 0x1f83d9abul, 0x5be0cd19ul }, \
{ { 0 } }, 0 }
#endif
/**
...
...
ccan/crypto/sha256/test/run-33-bit-test.c
View file @
e05d1ff2
...
...
@@ -30,9 +30,9 @@ static const struct sha256_ctx after_16M_by_64 = {
LE32_TO_CPU
(
0xd407a8fc
),
LE32_TO_CPU
(
0x1fad409b
),
LE32_TO_CPU
(
0x51fa46cc
),
LE32_TO_CPU
(
0xea528ae5
),
LE32_TO_CPU
(
0x5fa58ebb
),
LE32_TO_CPU
(
0x8be97931
)
},
1073741824
,
{
.
u32
=
{
0x64636261
,
0x68676665
,
0x65646362
,
0x69686766
,
0x66656463
,
0x6a696867
,
0x67666564
,
0x6b6a6968
}
}
0x66656463
,
0x6a696867
,
0x67666564
,
0x6b6a6968
}
},
1073741824
#endif
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment