I am trying to verify a certificate signature on my own. To do this, I created a self-signed certificate using OpenSSL with the two following command lines:
openssl ecparam -name secp256k1 -genkey -param_enc explicit -out private-key.pem
openssl req -new -x509 -key private-key.pem -out server.pem -days 730
You can take a look at my certificate here.
I can clearly distinguish the public key and the signature which respectively are:
public key
93 99 FD 9F 7F 04 48 AF 51 2C 6D 2D 69 04 B9 1F 88 A9 C2 64 31 8E 68 70 5B 55 C8 63 C2 C3 AC A4 17 BD 89 1A 5E 8E 08 C4 B7 92 AD AF 51 28 D3 AC BC CE 73 FA 5D D2 FE A7 EB 53 C7 6E 1A 00 84 2C
signature
32 BA FB EB A8 E9 BB 4B 2D 2B 19 12 65 11 EC BB F5 46 5E B5 59 3A 9D 42 F2 62 74 BA A0 E7 73 03 E1 4C CE 67 2B 7D 3B BA 75 E9 8B 95 95 57 E7 17 B7 C1 99 4B 71 96 74 89 67 5F DC B1 0C 71 3B 5F
My problem is that I don't understand what is the input of the signature algorithm (ECDSA with SHA256)?
I tried to verify the signature by performing ECC computations on a hash (SHA256) of all the data before the signature TLV (i.e. all except 03 48 00 30 45 02 20 32 BA FB EB A8 E9 BB 4B 2D 2B 19 12 65 11 EC BB F5 46 5E B5 59 3A 9D 42 F2 62 74 BA A0 E7 73 03 02 21 00 E1 4C CE 67 2B 7D 3B BA 75 E9 8B 95 95 57 E7 17 B7 C1 99 4B 71 96 74 89 67 5F DC B1 0C 71 3B 5F) but it seems that the signature is not valid with this input.