Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
external
mbedtls
Commits
96d59120
Commit
96d59120
authored
Aug 09, 2013
by
Manuel Pégourié-Gonnard
Browse files
Implement EC cert and crl verification
parent
211a64c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
9 deletions
+36
-9
library/x509parse.c
library/x509parse.c
+36
-9
No files found.
library/x509parse.c
View file @
96d59120
...
@@ -3305,6 +3305,7 @@ int x509parse_revoked( const x509_cert *crt, const x509_crl *crl )
...
@@ -3305,6 +3305,7 @@ int x509parse_revoked( const x509_cert *crt, const x509_crl *crl )
static
int
x509parse_verifycrl
(
x509_cert
*
crt
,
x509_cert
*
ca
,
static
int
x509parse_verifycrl
(
x509_cert
*
crt
,
x509_cert
*
ca
,
x509_crl
*
crl_list
)
x509_crl
*
crl_list
)
{
{
int
ret
;
int
flags
=
0
;
int
flags
=
0
;
unsigned
char
hash
[
POLARSSL_MD_MAX_SIZE
];
unsigned
char
hash
[
POLARSSL_MD_MAX_SIZE
];
const
md_info_t
*
md_info
;
const
md_info_t
*
md_info
;
...
@@ -3360,9 +3361,20 @@ static int x509parse_verifycrl(x509_cert *crt, x509_cert *ca,
...
@@ -3360,9 +3361,20 @@ static int x509parse_verifycrl(x509_cert *crt, x509_cert *ca,
else
else
#endif
/* POLARSSL_RSA_C */
#endif
/* POLARSSL_RSA_C */
#if defined(POLARSSL_ECDSA_C)
#if defined(POLARSSL_ECDSA_C)
if
(
ca
->
pk
.
type
==
POLARSSL_PK_ECKEY
)
{
if
(
pk_can_ecdsa
(
ca
->
pk
)
)
{
/* EC NOT IMPLEMENTED YET */
if
(
(
ret
=
pk_ec_to_ecdsa
(
&
ca
->
pk
)
)
!=
0
)
return
(
POLARSSL_ERR_X509_FEATURE_UNAVAILABLE
);
return
(
ret
);
if
(
ecdsa_read_signature
(
(
ecdsa_context
*
)
ca
->
pk
.
data
,
hash
,
md_info
->
size
,
crl_list
->
sig
.
p
,
crl_list
->
sig
.
len
)
!=
0
)
{
/*
* CRL is not trusted
*/
flags
|=
BADCRL_NOT_TRUSTED
;
break
;
}
}
}
else
else
#endif
/* POLARSSL_ECDSA_C */
#endif
/* POLARSSL_ECDSA_C */
...
@@ -3490,9 +3502,17 @@ static int x509parse_verify_top(
...
@@ -3490,9 +3502,17 @@ static int x509parse_verify_top(
else
else
#endif
/* POLARSSL_RSA_C */
#endif
/* POLARSSL_RSA_C */
#if defined(POLARSSL_ECDSA_C)
#if defined(POLARSSL_ECDSA_C)
if
(
trust_ca
->
pk
.
type
==
POLARSSL_PK_ECKEY
)
{
if
(
pk_can_ecdsa
(
trust_ca
->
pk
)
)
{
/* EC NOT IMPLEMENTED YET */
if
(
(
ret
=
pk_ec_to_ecdsa
(
&
trust_ca
->
pk
)
)
!=
0
)
return
(
POLARSSL_ERR_X509_FEATURE_UNAVAILABLE
);
return
(
ret
);
if
(
ecdsa_read_signature
(
(
ecdsa_context
*
)
trust_ca
->
pk
.
data
,
hash
,
md_info
->
size
,
child
->
sig
.
p
,
child
->
sig
.
len
)
!=
0
)
{
trust_ca
=
trust_ca
->
next
;
continue
;
}
}
}
else
else
#endif
/* POLARSSL_ECDSA_C */
#endif
/* POLARSSL_ECDSA_C */
...
@@ -3579,9 +3599,16 @@ static int x509parse_verify_child(
...
@@ -3579,9 +3599,16 @@ static int x509parse_verify_child(
else
else
#endif
/* POLARSSL_RSA_C */
#endif
/* POLARSSL_RSA_C */
#if defined(POLARSSL_ECDSA_C)
#if defined(POLARSSL_ECDSA_C)
if
(
parent
->
pk
.
type
==
POLARSSL_PK_ECKEY
)
{
if
(
pk_can_ecdsa
(
parent
->
pk
)
)
{
/* EC NOT IMPLEMENTED YET */
if
(
(
ret
=
pk_ec_to_ecdsa
(
&
parent
->
pk
)
)
!=
0
)
return
(
POLARSSL_ERR_X509_FEATURE_UNAVAILABLE
);
return
(
ret
);
if
(
ecdsa_read_signature
(
(
ecdsa_context
*
)
parent
->
pk
.
data
,
hash
,
md_info
->
size
,
child
->
sig
.
p
,
child
->
sig
.
len
)
!=
0
)
{
*
flags
|=
BADCERT_NOT_TRUSTED
;
}
}
}
else
else
#endif
/* POLARSSL_ECDSA_C */
#endif
/* POLARSSL_ECDSA_C */
...
...
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