Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
248b25f8
Commit
248b25f8
authored
Mar 13, 2007
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s/context/ctx/
Originally committed as revision 8385 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
e657aa34
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
29 deletions
+29
-29
sha1.c
libavutil/sha1.c
+29
-29
No files found.
libavutil/sha1.c
View file @
248b25f8
...
...
@@ -76,53 +76,53 @@ static void transform(uint32_t state[5], uint8_t buffer[64]){
state
[
4
]
+=
e
;
}
void
av_sha1_init
(
AVSHA1
*
c
ontext
){
c
ontext
->
state
[
0
]
=
0x67452301
;
c
ontext
->
state
[
1
]
=
0xEFCDAB89
;
c
ontext
->
state
[
2
]
=
0x98BADCFE
;
c
ontext
->
state
[
3
]
=
0x10325476
;
c
ontext
->
state
[
4
]
=
0xC3D2E1F0
;
c
ontext
->
count
=
0
;
void
av_sha1_init
(
AVSHA1
*
c
tx
){
c
tx
->
state
[
0
]
=
0x67452301
;
c
tx
->
state
[
1
]
=
0xEFCDAB89
;
c
tx
->
state
[
2
]
=
0x98BADCFE
;
c
tx
->
state
[
3
]
=
0x10325476
;
c
tx
->
state
[
4
]
=
0xC3D2E1F0
;
c
tx
->
count
=
0
;
}
void
av_sha1_update
(
AVSHA1
*
c
ontext
,
uint8_t
*
data
,
unsigned
int
len
){
void
av_sha1_update
(
AVSHA1
*
c
tx
,
uint8_t
*
data
,
unsigned
int
len
){
unsigned
int
i
,
j
;
j
=
c
ontext
->
count
&
63
;
c
ontext
->
count
+=
len
;
j
=
c
tx
->
count
&
63
;
c
tx
->
count
+=
len
;
#ifdef CONFIG_SMALL
for
(
i
=
0
;
i
<
len
;
i
++
){
c
ontext
->
buffer
[
j
++
]
=
data
[
i
];
c
tx
->
buffer
[
j
++
]
=
data
[
i
];
if
(
64
==
j
){
transform
(
c
ontext
->
state
,
context
->
buffer
);
transform
(
c
tx
->
state
,
ctx
->
buffer
);
j
=
0
;
}
}
#else
if
((
j
+
len
)
>
63
)
{
memcpy
(
&
c
ontext
->
buffer
[
j
],
data
,
(
i
=
64
-
j
));
transform
(
c
ontext
->
state
,
context
->
buffer
);
memcpy
(
&
c
tx
->
buffer
[
j
],
data
,
(
i
=
64
-
j
));
transform
(
c
tx
->
state
,
ctx
->
buffer
);
for
(
;
i
+
63
<
len
;
i
+=
64
)
{
transform
(
c
ontext
->
state
,
&
data
[
i
]);
transform
(
c
tx
->
state
,
&
data
[
i
]);
}
j
=
0
;
}
else
i
=
0
;
memcpy
(
&
c
ontext
->
buffer
[
j
],
&
data
[
i
],
len
-
i
);
memcpy
(
&
c
tx
->
buffer
[
j
],
&
data
[
i
],
len
-
i
);
#endif
}
void
av_sha1_final
(
AVSHA1
*
c
ontext
,
uint8_t
digest
[
20
]){
void
av_sha1_final
(
AVSHA1
*
c
tx
,
uint8_t
digest
[
20
]){
int
i
;
uint64_t
finalcount
=
be2me_64
(
c
ontext
->
count
<<
3
);
uint64_t
finalcount
=
be2me_64
(
c
tx
->
count
<<
3
);
av_sha1_update
(
c
ontext
,
"
\200
"
,
1
);
while
((
c
ontext
->
count
&
63
)
!=
56
)
{
av_sha1_update
(
c
ontext
,
""
,
1
);
av_sha1_update
(
c
tx
,
"
\200
"
,
1
);
while
((
c
tx
->
count
&
63
)
!=
56
)
{
av_sha1_update
(
c
tx
,
""
,
1
);
}
av_sha1_update
(
c
ontext
,
&
finalcount
,
8
);
/* Should cause a transform() */
av_sha1_update
(
c
tx
,
&
finalcount
,
8
);
/* Should cause a transform() */
for
(
i
=
0
;
i
<
5
;
i
++
)
((
uint32_t
*
)
digest
)[
i
]
=
be2me_32
(
c
ontext
->
state
[
i
]);
((
uint32_t
*
)
digest
)[
i
]
=
be2me_32
(
c
tx
->
state
[
i
]);
}
// use the following to test
...
...
@@ -133,19 +133,19 @@ void av_sha1_final(AVSHA1* context, uint8_t digest[20]){
int
main
(){
int
i
,
k
;
AVSHA1
c
ontext
;
AVSHA1
c
tx
;
unsigned
char
digest
[
20
];
for
(
k
=
0
;
k
<
3
;
k
++
){
av_sha1_init
(
&
c
ontext
);
av_sha1_init
(
&
c
tx
);
if
(
k
==
0
)
av_sha1_update
(
&
c
ontext
,
"abc"
,
3
);
av_sha1_update
(
&
c
tx
,
"abc"
,
3
);
else
if
(
k
==
1
)
av_sha1_update
(
&
c
ontext
,
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
,
56
);
av_sha1_update
(
&
c
tx
,
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
,
56
);
else
for
(
i
=
0
;
i
<
1000
*
1000
;
i
++
)
av_sha1_update
(
&
c
ontext
,
"a"
,
1
);
av_sha1_final
(
&
c
ontext
,
digest
);
av_sha1_update
(
&
c
tx
,
"a"
,
1
);
av_sha1_final
(
&
c
tx
,
digest
);
for
(
i
=
0
;
i
<
20
;
i
++
)
printf
(
"%02X"
,
digest
[
i
]);
putchar
(
'\n'
);
...
...
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