# std.crypto.sign.ecdsa: accepts unusual parameters like EcdsaP384Sha256 \(\#13302\) · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/cd4865d88c368095e131d2d95d3cce637db0ff5a)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: cd4865d88c368095e131d2d95d3cce637db0ff5a

Requested commit: cd4865d88c368095e131d2d95d3cce637db0ff5a

Commit: cd4865d88c368095e131d2d95d3cce637db0ff5a

Tree: bacfeebb1515a9454818786b180c5e188009012a

Author: Naoki MATSUMOTO

Committer: GitHub

## Message

```
std.crypto.sign.ecdsa: accepts unusual parameters like EcdsaP384Sha256 (#13302)

This commit accepts unusual parameters like EcdsaP384Sha256.
Some certifictes(below certs are in /etc/ssl/certs/ca-certificates.crt on Ubuntu 22.04) use EcdsaP384Sha256 to sign itself.
- Subject: C=GR, L=Athens, O=Hellenic Academic and Research Institutions Cert. Authority, CN=Hellenic Academic and Research Institutions ECC RootCA 2015
- Subject: C=US, ST=Texas, L=Houston, O=SSL Corporation, CN=SSL.com EV Root Certification Authority ECC
- Subject: C=US, ST=Texas, L=Houston, O=SSL Corporation, CN=SSL.com Root Certification Authority ECC

In verify(), hash array `h` is allocated to be larger than the scalar.encoded_length.
The array is regarded as big-endian.
Hash values are filled in the back of the array and the rest bytes in front are filled with zero.

In sign(), the hash array is allocated and filled as same as verify().
In deterministicScalar(), hash bytes are insufficient to generate `k`
To generate `k` without narrowing its value range,
this commit uses algorithm stage h. in  "Section 3.2 Generation of k" in RFC6979.
```

## Parents

- [22b71b1376eaa75aa141022404d6ddf40495c886](https://git.cafe/gitcafe/zig/commit/22b71b1376eaa75aa141022404d6ddf40495c886?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/cd4865d88c368095e131d2d95d3cce637db0ff5a?format=markdown)
