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
With ECC if you try and sign a hash that is bigger than your ECC key you can run into problems. The math will still work
3152
3152
and in effect the signature will still work. With ECC keys the strength of the signature is limited by the size of
3153
-
the hash or the size of they key, whichever is smaller. For example, if you sign with SHA256 and a ECC-160 key in effect
3154
-
you have 160-bits of security (e.g. as if you signed with SHA-1).
3153
+
the hash or the size of they key, whichever is smaller. For example, if you sign with SHA256 and an ECC-192 key in effect
3154
+
you have 192-bits of security.
3155
3155
3156
3156
The library will not warn you if you make this mistake so it is important to check yourself before using the
3157
3157
signatures.
@@ -3324,7 +3324,7 @@ \section{ASN.1 Formats}
3324
3324
are all provided with three basic functions with \textit{similar} prototypes. One function has been dedicated to calculate the length in octets of a given
3325
3325
format and two functions have been dedicated to encoding and decoding the format.
3326
3326
3327
-
On top of the basic data types are the SEQUENCE and\footnote{Planned for LTC 1.04} SET data types which are collections of other ASN.1 types. They are provided
3327
+
On top of the basic data types are the SEQUENCE and\footnote{Planned for LTC 1.06} SET data types which are collections of other ASN.1 types. They are provided
3328
3328
in the same manner as the other data types except they use list of objects known as the \textbf{ltc\_asn1\_list} structure. It is defined as
3329
3329
3330
3330
\index{ltc\_asn1\_list structure}
@@ -3333,11 +3333,13 @@ \section{ASN.1 Formats}
3333
3333
int type;
3334
3334
void *data;
3335
3335
unsigned long size;
3336
+
int used;
3336
3337
} ltc_asn1_list;
3337
3338
\end{verbatim}
3338
3339
3339
3340
The ``type'' field is one of the following ASN.1 field definitions. The ``data'' pointer is a void pointer to the data to be encoded (or the destination) and the
3340
-
``size'' field is specific to what you are encoding (e.g. number of bits in the BIT STRING data type). To help build the lists in an orderly fashion the macro
3341
+
``size'' field is specific to what you are encoding (e.g. number of bits in the BIT STRING data type). The ``used'' field is primarily for the CHOICE decoder
3342
+
and reflects if the particular member of a list was the decoded data type. To help build the lists in an orderly fashion the macro
3341
3343
``LTC\_SET\_ASN1(list, index, Type, Data, Size)'' has been provided.
3342
3344
3343
3345
It will assign to the ``index''th position in the ``list'' the tripplet (Type, Data, Size). An example usage would be:
@@ -3382,7 +3384,9 @@ \section{ASN.1 Formats}
3382
3384
\hline LTC\_ASN1\_OBJECT\_IDENTIFIER & OBJECT IDENTIFIER (words are in unsigned long) \\
3383
3385
\hline LTC\_ASN1\_IA5\_STRING & IA5 STRING (one octet per char) \\
3384
3386
\hline LTC\_ASN1\_PRINTABLE\_STRING & PRINTABLE STIRNG (one octet per char) \\
3387
+
\hline LTC\_ASN1\_UTCTIME & UTCTIME (see ltc\_utctime structure) \\
It's ideal that you cast the ``size'' values to unsigned long to ensure that the proper data type is passed to the function. Constants such as ``1'' without
3467
3471
a cast or prototype are of type \textbf{int} by default. Appending \textit{UL} or prepending \textit{(unsigned long)} is enough to cast it to the correct type.
3468
3472
3469
-
\subsubsection{ASN.1 INTEGER}
3473
+
\subsection{ASN.1 INTEGER}
3470
3474
3471
3475
To encode or decode INTEGER data types use the following functions.
These will encode or decode an unsigned \textbf{unsigned long} type (only reads upto 32--bits). For values in the range $0\dots2^{32} - 1$ the integer
3499
3503
and short integer functions can encode and decode each others outputs.
3500
3504
3501
-
\subsubsection{ASN.1 BIT STRING}
3505
+
\subsection{ASN.1 BIT STRING}
3502
3506
3503
3507
\index{der\_encode\_bit\_string()}
3504
3508
\index{der\_decode\_bit\_string()}
@@ -3516,7 +3520,7 @@ \subsubsection{ASN.1 BIT STRING}
3516
3520
These will encode or decode a BIT STRING data type. The bits are passed in (or read out) using one \textbf{char} per bit. A non--zero value will be interpretted
These will encode or decode an OBJECT IDENTIFIER object. The words of the OID are stored in individual \textbf{unsigned long} elements and must be in the range
The time can be offset plus or minus a set amount of hours (off\_hh) and minutes (off\_mm). When ``off\_dir'' is zero the time will be added otherwise it
3624
+
will be subtracted.
3625
+
3626
+
For instance, the array $\lbrace5, 6, 20, 22, 4, 00, 0, 5, 0\rbrace$ represents the current time of 2005, June 20th, 22:04:00 with a time offset of +05h00.
3627
+
3628
+
\index{der\_encode\_utctime()}
3629
+
\index{der\_decode\_utctime()}
3630
+
\index{der\_length\_utctime()}
3631
+
\begin{verbatim}
3632
+
int der_encode_utctime(ltc_utctime *utctime,
3633
+
unsigned char *out, unsigned long *outlen);
3634
+
3635
+
int der_decode_utctime(const unsigned char *in, unsigned long *inlen,
3636
+
ltc_utctime *out);
3637
+
3638
+
int der_length_utctime(ltc_utctime *utctime, unsigned long *outlen);
3639
+
\end{verbatim}
3640
+
3641
+
The encoder will store time in one of the two ASN.1 formats, either ``YYMMDDhhmmssZ'' or ``YYMMDDhhmmss$\pm$hhmm'' and perform minimal error checking on the
3642
+
input. The decoder will read all valid ASN.1 formats and perform range checking on the values (not complete but rational) useful for catching packet errors.
3643
+
3644
+
It is suggested that decoded data be further scrutinized (e.g. days of month in particular).
3645
+
3646
+
\subsection{ASN.1 CHOICE}
3647
+
3648
+
The CHOICE ASN.1 type represents a union of ASN.1 types all of which are stored in a ``ltc\_asn1\_list''. There is no encoder for the CHOICE type, only a
3649
+
decoder. The decoder will scan through the provided list attempting to use the appropriate decoder on the input packet. The list can contain any ASN.1 data
3650
+
type\footnote{Except it cannot have LTC\_ASN1\_INTEGER and LTC\_ASN1\_SHORT\_INTEGER simultaneously.} except for other CHOICE types.
3651
+
3652
+
There is no encoder for the CHOICE type as the actual DER encoding is the encoding of the chosen type.
3653
+
3654
+
\index{der\_decode\_choice()}
3655
+
\begin{verbatim}
3656
+
int der_decode_choice(const unsigned char *in, unsigned long *inlen,
3657
+
ltc_asn1_list *list, unsigned long outlen);
3658
+
\end{verbatim}
3659
+
3660
+
This will decode the input in the ``in'' field of length ``inlen''. It uses the provided ASN.1 list specified in the ``list'' field which has ``outlen'' elements.
3661
+
The ``inlen'' field will be updated with the length of the decoded data type as well as the respective entry in the ``list'' field will have the ``used'' flag
3662
+
set to non--zero to reflect it was the data type decoded.
0 commit comments