Add size querying for ECDSA curves.
This commit is contained in:
@@ -7,6 +7,7 @@ pub trait EllipticCurve {
|
||||
type Unsigned : Clone;
|
||||
type Signed : Clone;
|
||||
|
||||
fn size() -> usize;
|
||||
fn p() -> Self::Unsigned;
|
||||
fn n() -> Self::Unsigned;
|
||||
fn SEED() -> Self::Unsigned;
|
||||
@@ -23,6 +24,10 @@ impl EllipticCurve for P192 {
|
||||
type Unsigned = U192;
|
||||
type Signed = I192;
|
||||
|
||||
fn size() -> usize {
|
||||
192
|
||||
}
|
||||
|
||||
fn p() -> U192 {
|
||||
U192::from_bytes(&[0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
|
||||
@@ -82,6 +87,10 @@ impl EllipticCurve for P224 {
|
||||
type Unsigned = U256;
|
||||
type Signed = I256;
|
||||
|
||||
fn size() -> usize {
|
||||
224
|
||||
}
|
||||
|
||||
fn p() -> U256 {
|
||||
U256::from_bytes(&[
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
@@ -160,6 +169,10 @@ impl EllipticCurve for P256 {
|
||||
type Signed = I256;
|
||||
type Unsigned = U256;
|
||||
|
||||
fn size() -> usize {
|
||||
256
|
||||
}
|
||||
|
||||
fn p() -> U256 {
|
||||
U256::from_bytes(&[
|
||||
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01,
|
||||
@@ -239,6 +252,10 @@ impl EllipticCurve for P384 {
|
||||
type Signed = I384;
|
||||
type Unsigned = U384;
|
||||
|
||||
fn size() -> usize {
|
||||
384
|
||||
}
|
||||
|
||||
fn p() -> U384 {
|
||||
U384::from_bytes(&[
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
@@ -331,6 +348,10 @@ impl EllipticCurve for P521 {
|
||||
type Signed = I576;
|
||||
type Unsigned = U576;
|
||||
|
||||
fn size() -> usize {
|
||||
521
|
||||
}
|
||||
|
||||
fn p() -> U576 {
|
||||
U576::from_bytes(&[
|
||||
0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
|
||||
Reference in New Issue
Block a user