API
#crypto/ecdsa
Xu 0.8.8 API
import: #crypto/ecdsa
counts: 15 fns, 0 methods, 0 types, 9 consts, 0 ifaces
crypto/ecdsa verification subset. Public keys use SEC1 uncompressed P-256/P-384/P-521 form (0x04 || X || Y); signatures use ASN.1 DER SEQUENCE{r,s}. The curve is selected explicitly for key generation and by canonical raw-key length for public/sign operations. Signing uses the platform-independent CSPRNG exposed by crypto/rand. XU-CT-CLASS: variable-time Point/scalar arithmetic is math/big based. ECDSA and ECDH therefore have no constant-time contract even where final equality uses crypto/subtle.
const public_key_size_p256
pub const public_key_size_p256 = 65
Purpose
crypto/ecdsa verification subset. Public keys use SEC1 uncompressed P-256/P-384/P-521 form (0x04 || X || Y); signatures use ASN.1 DER SEQUENCE{r,s}. The curve is selected explicitly for key generation and by canonical raw-key length for public/sign operations. Signing uses the platform-independent CSPRNG exposed by crypto/rand. XU-CT-CLASS: variable-time Point/scalar arithmetic is math/big based. ECDSA and ECDH therefore have no constant-time contract even where final equality uses crypto/subtle. Value `65`.
Parameters
none
const public_key_size_p384
pub const public_key_size_p384 = 97
Purpose
Public constant `public_key_size_p384`. Value `97`.
Parameters
none
const public_key_size_p521
pub const public_key_size_p521 = 133
Purpose
Public constant `public_key_size_p521`. Value `133`.
Parameters
none
const private_key_size_p256
pub const private_key_size_p256 = 32
Purpose
Public constant `private_key_size_p256`. Value `32`.
Parameters
none
const private_key_size_p384
pub const private_key_size_p384 = 48
Purpose
Public constant `private_key_size_p384`. Value `48`.
Parameters
none
const private_key_size_p521
pub const private_key_size_p521 = 66
Purpose
Public constant `private_key_size_p521`. Value `66`.
Parameters
none
const p256
Purpose
Public constant `p256`. Value `256`.
Parameters
none
const p384
Purpose
Public constant `p384`. Value `384`.
Parameters
none
const p521
Purpose
Public constant `p521`. Value `521`.
Parameters
none
generate_key
pub fn generate_key(curve int) string
Purpose
Generate key. Throws on failure.
Parameters
curve int- curve (int)
Returns
string — result string
public
pub fn public(private_key &string) string
Purpose
public; returns string. Throws on failure.
Parameters
private_key &string- private_key (borrowed; caller keeps it; type &string)
Returns
string — result string
ecdh
pub fn ecdh(private_key &string, peer_public &string) string
Purpose
ecdh returns the fixed-width shared X coordinate for P-256/P-384/P-521. The curve is inferred from the private-key width and must match the peer SEC1 uncompressed public-key width. Throws on failure.
Parameters
private_key &string- private_key (borrowed; caller keeps it; type &string)
peer_public &string- peer_public (borrowed; caller keeps it; type &string)
Returns
string — result string
sign_asn1
pub fn sign_asn1(private_key &string, hash &string) string
Purpose
Sign asn1. Throws on failure.
Parameters
private_key &string- private_key (borrowed; caller keeps it; type &string)
hash &string- hash (borrowed; caller keeps it; type &string)
Returns
string — result string
verify_asn1
pub fn verify_asn1(public_key &string, hash &string, signature &string) bool
Purpose
Verify asn1.
Parameters
public_key &string- public_key (borrowed; caller keeps it; type &string)
hash &string- hash (borrowed; caller keeps it; type &string)
signature &string- signature (borrowed; caller keeps it; type &string)
Returns
bool — true or false
parse_private_key
pub fn parse_private_key(der &string) string
Purpose
Parse as private key. Throws on failure.
Parameters
der &string- der (borrowed; caller keeps it; type &string)
Returns
string — result string
marshal_sec1
pub fn marshal_sec1(private_key &string) string
Purpose
Marshal sec1.
Parameters
private_key &string- private_key (borrowed; caller keeps it; type &string)
Returns
string — result string
marshal_pkcs8
pub fn marshal_pkcs8(private_key &string) string
Purpose
Marshal pkcs8. Throws on failure.
Parameters
private_key &string- private_key (borrowed; caller keeps it; type &string)
Returns
string — result string
parse_private_pem
pub fn parse_private_pem(text &string) string
Purpose
Parse as private pem. Throws on failure.
Parameters
text &string- text (borrowed; caller keeps it; type &string)
Returns
string — result string
marshal_pkcs8_pem
pub fn marshal_pkcs8_pem(private_key &string) string
Purpose
Marshal pkcs8 pem. Throws on failure.
Parameters
private_key &string- private_key (borrowed; caller keeps it; type &string)
Returns
string — result string
marshal_sec1_pem
pub fn marshal_sec1_pem(private_key &string) string
Purpose
Marshal sec1 pem. Throws on failure.
Parameters
private_key &string- private_key (borrowed; caller keeps it; type &string)
Returns
string — result string
parse_public_key
pub fn parse_public_key(der &string) string
Purpose
Parse as public key. Throws on failure.
Parameters
der &string- der (borrowed; caller keeps it; type &string)
Returns
string — result string
marshal_pkix
pub fn marshal_pkix(public_key &string) string
Purpose
Marshal pkix. Throws on failure.
Parameters
public_key &string- public_key (borrowed; caller keeps it; type &string)
Returns
string — result string
parse_public_pem
pub fn parse_public_pem(text &string) string
Purpose
Parse as public pem. Throws on failure.
Parameters
text &string- text (borrowed; caller keeps it; type &string)
Returns
string — result string
marshal_pkix_pem
pub fn marshal_pkix_pem(public_key &string) string
Purpose
Marshal pkix pem. Throws on failure.
Parameters
public_key &string- public_key (borrowed; caller keeps it; type &string)
Returns
string — result string