Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nettle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Nettle
nettle
Commits
5549b2f4
Commit
5549b2f4
authored
Mar 26, 2014
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert dsa_keypair_from_sexp_alist to use struct dsa_params.
parent
fb4e324a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
25 deletions
+53
-25
ChangeLog
ChangeLog
+6
-0
dsa.h
dsa.h
+9
-6
examples/hogweed-benchmark.c
examples/hogweed-benchmark.c
+3
-1
sexp2dsa.c
sexp2dsa.c
+35
-18
No files found.
ChangeLog
View file @
5549b2f4
2014-03-26 Niels Möller <nisse@lysator.liu.se>
2014-03-26 Niels Möller <nisse@lysator.liu.se>
* sexp2dsa.c (dsa_keypair_from_sexp_alist): Converted to new DSA
interface. Allow q_size == 0, meaning any q < p is allowed.
Additional validity checks.
(dsa_sha1_keypair_from_sexp, dsa_sha256_keypair_from_sexp):
Converted to new DSA interface.
* dsa2sexp.c (dsa_keypair_to_sexp): Converted to new DSA
* dsa2sexp.c (dsa_keypair_to_sexp): Converted to new DSA
interface.
interface.
* tools/pkcs1-conv.c: Updated uses of dsa_keypair_to_sexp.
* tools/pkcs1-conv.c: Updated uses of dsa_keypair_to_sexp.
...
...
dsa.h
View file @
5549b2f4
...
@@ -256,8 +256,9 @@ dsa_signature_from_sexp(struct dsa_signature *rs,
...
@@ -256,8 +256,9 @@ dsa_signature_from_sexp(struct dsa_signature *rs,
unsigned
q_bits
);
unsigned
q_bits
);
int
int
dsa_keypair_from_sexp_alist
(
struct
dsa_public_key
*
pub
,
dsa_keypair_from_sexp_alist
(
struct
dsa_params
*
params
,
struct
dsa_private_key
*
priv
,
mpz_t
pub
,
mpz_t
priv
,
unsigned
p_max_bits
,
unsigned
p_max_bits
,
unsigned
q_bits
,
unsigned
q_bits
,
struct
sexp_iterator
*
i
);
struct
sexp_iterator
*
i
);
...
@@ -267,14 +268,16 @@ dsa_keypair_from_sexp_alist(struct dsa_public_key *pub,
...
@@ -267,14 +268,16 @@ dsa_keypair_from_sexp_alist(struct dsa_public_key *pub,
* the public key. */
* the public key. */
/* Keys must be initialized before calling this function, as usual. */
/* Keys must be initialized before calling this function, as usual. */
int
int
dsa_sha1_keypair_from_sexp
(
struct
dsa_public_key
*
pub
,
dsa_sha1_keypair_from_sexp
(
struct
dsa_params
*
params
,
struct
dsa_private_key
*
priv
,
mpz_t
pub
,
mpz_t
priv
,
unsigned
p_max_bits
,
unsigned
p_max_bits
,
size_t
length
,
const
uint8_t
*
expr
);
size_t
length
,
const
uint8_t
*
expr
);
int
int
dsa_sha256_keypair_from_sexp
(
struct
dsa_public_key
*
pub
,
dsa_sha256_keypair_from_sexp
(
struct
dsa_params
*
params
,
struct
dsa_private_key
*
priv
,
mpz_t
pub
,
mpz_t
priv
,
unsigned
p_max_bits
,
unsigned
p_max_bits
,
size_t
length
,
const
uint8_t
*
expr
);
size_t
length
,
const
uint8_t
*
expr
);
...
...
examples/hogweed-benchmark.c
View file @
5549b2f4
...
@@ -303,7 +303,9 @@ bench_dsa_init (unsigned size)
...
@@ -303,7 +303,9 @@ bench_dsa_init (unsigned size)
if
(
!
(
sexp_transport_iterator_first
(
&
i
,
sizeof
(
dsa1024
)
-
1
,
dsa1024
)
if
(
!
(
sexp_transport_iterator_first
(
&
i
,
sizeof
(
dsa1024
)
-
1
,
dsa1024
)
&&
sexp_iterator_check_type
(
&
i
,
"private-key"
)
&&
sexp_iterator_check_type
(
&
i
,
"private-key"
)
&&
sexp_iterator_check_type
(
&
i
,
"dsa"
)
&&
sexp_iterator_check_type
(
&
i
,
"dsa"
)
&&
dsa_keypair_from_sexp_alist
(
&
ctx
->
pub
,
&
ctx
->
key
,
0
,
DSA_SHA1_Q_BITS
,
&
i
))
)
&&
dsa_keypair_from_sexp_alist
((
struct
dsa_params
*
)
&
ctx
->
pub
,
ctx
->
pub
.
y
,
ctx
->
key
.
x
,
0
,
DSA_SHA1_Q_BITS
,
&
i
))
)
die
(
"Internal error.
\n
"
);
die
(
"Internal error.
\n
"
);
ctx
->
digest
=
hash_string
(
&
nettle_sha1
,
3
,
"foo"
);
ctx
->
digest
=
hash_string
(
&
nettle_sha1
,
3
,
"foo"
);
...
...
sexp2dsa.c
View file @
5549b2f4
...
@@ -47,8 +47,9 @@ do { \
...
@@ -47,8 +47,9 @@ do { \
*/
*/
int
int
dsa_keypair_from_sexp_alist
(
struct
dsa_public_key
*
pub
,
dsa_keypair_from_sexp_alist
(
struct
dsa_params
*
params
,
struct
dsa_private_key
*
priv
,
mpz_t
pub
,
mpz_t
priv
,
unsigned
p_max_bits
,
unsigned
p_max_bits
,
unsigned
q_bits
,
unsigned
q_bits
,
struct
sexp_iterator
*
i
)
struct
sexp_iterator
*
i
)
...
@@ -57,26 +58,39 @@ dsa_keypair_from_sexp_alist(struct dsa_public_key *pub,
...
@@ -57,26 +58,39 @@ dsa_keypair_from_sexp_alist(struct dsa_public_key *pub,
=
{
"p"
,
"q"
,
"g"
,
"y"
,
"x"
};
=
{
"p"
,
"q"
,
"g"
,
"y"
,
"x"
};
struct
sexp_iterator
values
[
5
];
struct
sexp_iterator
values
[
5
];
unsigned
nvalues
=
priv
?
5
:
4
;
unsigned
nvalues
=
priv
?
5
:
4
;
unsigned
p_bits
;
if
(
!
sexp_iterator_assoc
(
i
,
nvalues
,
names
,
values
))
if
(
!
sexp_iterator_assoc
(
i
,
nvalues
,
names
,
values
))
return
0
;
return
0
;
if
(
priv
)
GET
(
params
->
p
,
p_max_bits
,
&
values
[
0
]);
GET
(
priv
->
x
,
q_bits
,
&
values
[
4
]);
p_bits
=
mpz_sizeinbase
(
params
->
p
,
2
);
GET
(
params
->
q
,
q_bits
?
q_bits
:
p_bits
,
&
values
[
1
]);
GET
(
pub
->
p
,
p_max_bits
,
&
values
[
0
]);
if
(
q_bits
>
0
&&
mpz_sizeinbase
(
params
->
q
,
2
)
!=
q_bits
)
GET
(
pub
->
q
,
q_bits
,
&
values
[
1
]);
return
0
;
if
(
mpz_sizeinbase
(
pub
->
q
,
2
)
!=
q_bits
)
if
(
mpz_cmp
(
params
->
q
,
params
->
p
)
>=
0
)
return
0
;
GET
(
params
->
g
,
p_bits
,
&
values
[
2
]);
if
(
mpz_cmp
(
params
->
g
,
params
->
p
)
>=
0
)
return
0
;
return
0
;
GET
(
pub
->
g
,
p_max_bits
,
&
values
[
2
]);
GET
(
pub
,
p_bits
,
&
values
[
3
]);
GET
(
pub
->
y
,
p_max_bits
,
&
values
[
3
]);
if
(
mpz_cmp
(
pub
,
params
->
p
)
>=
0
)
return
0
;
if
(
priv
)
{
GET
(
priv
,
mpz_sizeinbase
(
params
->
q
,
2
),
&
values
[
4
]);
if
(
mpz_cmp
(
priv
,
params
->
q
)
>=
0
)
return
0
;
}
return
1
;
return
1
;
}
}
int
int
dsa_sha1_keypair_from_sexp
(
struct
dsa_public_key
*
pub
,
dsa_sha1_keypair_from_sexp
(
struct
dsa_params
*
params
,
struct
dsa_private_key
*
priv
,
mpz_t
pub
,
mpz_t
priv
,
unsigned
p_max_bits
,
unsigned
p_max_bits
,
size_t
length
,
const
uint8_t
*
expr
)
size_t
length
,
const
uint8_t
*
expr
)
{
{
...
@@ -85,12 +99,14 @@ dsa_sha1_keypair_from_sexp(struct dsa_public_key *pub,
...
@@ -85,12 +99,14 @@ dsa_sha1_keypair_from_sexp(struct dsa_public_key *pub,
return
sexp_iterator_first
(
&
i
,
length
,
expr
)
return
sexp_iterator_first
(
&
i
,
length
,
expr
)
&&
sexp_iterator_check_type
(
&
i
,
priv
?
"private-key"
:
"public-key"
)
&&
sexp_iterator_check_type
(
&
i
,
priv
?
"private-key"
:
"public-key"
)
&&
sexp_iterator_check_type
(
&
i
,
"dsa"
)
&&
sexp_iterator_check_type
(
&
i
,
"dsa"
)
&&
dsa_keypair_from_sexp_alist
(
pub
,
priv
,
p_max_bits
,
DSA_SHA1_Q_BITS
,
&
i
);
&&
dsa_keypair_from_sexp_alist
(
params
,
pub
,
priv
,
p_max_bits
,
DSA_SHA1_Q_BITS
,
&
i
);
}
}
int
int
dsa_sha256_keypair_from_sexp
(
struct
dsa_public_key
*
pub
,
dsa_sha256_keypair_from_sexp
(
struct
dsa_params
*
params
,
struct
dsa_private_key
*
priv
,
mpz_t
pub
,
mpz_t
priv
,
unsigned
p_max_bits
,
unsigned
p_max_bits
,
size_t
length
,
const
uint8_t
*
expr
)
size_t
length
,
const
uint8_t
*
expr
)
{
{
...
@@ -99,7 +115,8 @@ dsa_sha256_keypair_from_sexp(struct dsa_public_key *pub,
...
@@ -99,7 +115,8 @@ dsa_sha256_keypair_from_sexp(struct dsa_public_key *pub,
return
sexp_iterator_first
(
&
i
,
length
,
expr
)
return
sexp_iterator_first
(
&
i
,
length
,
expr
)
&&
sexp_iterator_check_type
(
&
i
,
priv
?
"private-key"
:
"public-key"
)
&&
sexp_iterator_check_type
(
&
i
,
priv
?
"private-key"
:
"public-key"
)
&&
sexp_iterator_check_type
(
&
i
,
"dsa-sha256"
)
&&
sexp_iterator_check_type
(
&
i
,
"dsa-sha256"
)
&&
dsa_keypair_from_sexp_alist
(
pub
,
priv
,
p_max_bits
,
DSA_SHA256_Q_BITS
,
&
i
);
&&
dsa_keypair_from_sexp_alist
(
params
,
pub
,
priv
,
p_max_bits
,
DSA_SHA256_Q_BITS
,
&
i
);
}
}
int
int
...
...
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