You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are also functions to sign and verify messages. They use the ANSI X9.62 ECDSA algorithm to generate and verify signatures in the
5807
-
ANSI X9.62 format.
5806
+
There are also functions to sign and verify messages. They use the \textit{ANSI X9.62} \textit{ECDSA} algorithm to generate and verify signatures in the
5807
+
\textit{ANSI X9.62} format.
5808
+
5809
+
\textbf{BEWARE:} With \textit{ECC} if you try to sign a hash that is bigger than your \textit{ECC} key you can run into problems. The math
5810
+
will still work, and in effect the signature will still work. With \textit{ECC} keys the strength of the signature is limited
5811
+
by the size of the hash, or the size of the key, whichever is smaller. For example, if you sign with SHA256 and a
5812
+
P--192 key, you have in effect 96--bits of security. The library will not warn you if you make this mistake, so it
5813
+
is important to check yourself before using the signatures.
5808
5814
5809
5815
\subsection{Signature Generation}
5810
5816
To sign a message digest (hash) use the following function:
This function creates the same ECDSA signature as \textit{ecc\_sign\_hash} only the output format is different.
5844
+
This function creates the same \textit{ECDSA} signature as \code{ecc\_sign\_hash()} only the output format is different.
5839
5845
The format follows \url{https://tools.ietf.org/html/rfc7518#section-3.4}, sometimes it is also called plain signature.
5840
5846
5841
-
\index{ecc\_sign\_hash\_ex()}
5847
+
\index{ecc\_sign\_hash\_rfc7518\_ex()}
5842
5848
\begin{verbatim}
5843
-
int ecc_sign_hash_ex(const unsigned char *in,
5844
-
unsigned long inlen,
5845
-
unsigned char *out,
5846
-
unsigned long *outlen,
5847
-
prng_state *prng,
5848
-
int wprng,
5849
-
ecc_signature_type sigformat,
5850
-
int *recid,
5851
-
ecc_key *key);
5849
+
int ecc_sign_hash_rfc7518_ex(const unsigned char *in,
5850
+
unsigned long inlen,
5851
+
unsigned char *out,
5852
+
unsigned long *outlen,
5853
+
prng_state *prng,
5854
+
int wprng,
5855
+
int *recid,
5856
+
const ecc_key *key);
5852
5857
\end{verbatim}
5853
5858
5854
-
This function is an extended version of the ECDSA signature in \textit{ecc\_sign\_hash}, but with a choice of output formats
5855
-
and an optional output of the recovery ID for use with \textit{ecc\_recover\_key}.
5859
+
This function is an extended version of the \textit{ECDSA} signature in \code{ecc\_sign\_hash\_rfc7518()}, but with an additional output of the recovery ID
5860
+
for use with \code{ecc\_recover\_key()}.
5861
+
5862
+
\index{ecc\_sign\_hash\_rfc5656()}
5863
+
\begin{verbatim}
5864
+
int ecc_sign_hash_rfc5656(const unsigned char *in,
5865
+
unsigned long inlen,
5866
+
unsigned char *out,
5867
+
unsigned long *outlen,
5868
+
prng_state *prng,
5869
+
int wprng,
5870
+
const ecc_key *key);
5871
+
\end{verbatim}
5872
+
5873
+
This function creates an \textit{ECDSA} signature and the output format is according to \textit{RFC5656}, i.e. \textit{SSH} compatible.
5874
+
5875
+
\index{ecc\_sign\_hash\_eth27()}
5876
+
\begin{verbatim}
5877
+
int ecc_sign_hash_eth27(const unsigned char *in,
5878
+
unsigned long inlen,
5879
+
unsigned char *out,
5880
+
unsigned long *outlen,
5881
+
prng_state *prng,
5882
+
int wprng,
5883
+
const ecc_key *key);
5884
+
\end{verbatim}
5885
+
5886
+
This function creates an \textit{ECDSA} signature and the output format is according to the Ethereum format.
5887
+
With this API the curve is limited to \textit{secp256k1}.
This function will verify the ECDSA signature in the array pointed to by \textit{sig} of length \textit{siglen} octets, against the message digest
5869
-
pointed to by the array \textit{hash} of length \textit{hashlen}. It will store a non--zero value in \textit{stat} if the signature is valid. Note:
5900
+
This function will verify the \textit{ECDSA} signature in the array pointed to by \code{sig} of length \code{siglen} octets, against the message digest
5901
+
pointed to by the array \code{hash} of length \code{hashlen}. It will store a non--zero value in \code{stat} if the signature is valid. Note:
5870
5902
the function will not return an error if the signature is invalid. It will return an error, if the actual signature payload is an invalid format.
5871
-
The ECC\textit{key} must be the public (or private) ECC key corresponding to the key that performed the signature.
5872
-
The function \textit{ecc\_verify\_hash} implements signature format according to X9.62 ECDSA, and the output is compliant for GF(p) curves.
5903
+
The \textit{ECC} \code{key} must be the public (or private) \textit{ECC} key corresponding to the key that performed the signature.
5904
+
The function \code{ecc\_verify\_hash()} implements signature format according to \textit{ANSI X9.62} EC\textit{DSA}, and the output is compliant for GF(p) curves.
0 commit comments