Lines Matching full:read
40 \ -- A word called "read-blob-inner" ( addr len -- addr len ) that is
52 \ Read next source character, skipping blanks.
58 \ Read a decimal integer, followed by either a dot or whitespace.
102 \ Define a new data word for an encoded OID. The OID is read from the
159 \ Read one byte from the stream.
166 \ Read one byte, enforcing current read limit.
171 \ Read a 16-bit value, big-endian encoding.
175 \ Read a 16-bit value, little-endian encoding.
179 \ Read all bytes from the current element, then close it (i.e. drop the
181 : read-blob ( lim addr -- )
183 begin dup while read-blob-inner dup if co then repeat
192 0 over read-blob-inner -rot 2drop ;
224 \ Read an ASN.1 tag. This function returns the "constructed" status
232 : read-tag ( lim -- lim constructed value )
250 \ Read a tag, but only if not at the end of the current object. If there
253 : read-tag-or-end ( lim -- lim constructed value )
255 read-tag ;
257 \ Compare the read tag with the provided value. If equal, then the
258 \ element is skipped, and a new tag is read (or end of object).
262 read-length-open-elt skip-close-elt
263 read-tag-or-end
266 \ Read an ASN.1 length. This supports only definite lengths (theoretically,
271 : read-length ( lim -- lim length )
297 \ Read a length and open the value as a sub-structure.
298 : read-length-open-elt ( lim -- lim_outer lim_inner )
299 read-length open-elt ;
302 \ element to read.
310 \ Read a length and then skip the value.
311 : read-length-skip ( lim -- lim )
312 read-length-open-elt skip-close-elt ;
338 \ Read a tag, check that it is for a constructed SEQUENCE, and open
340 : read-sequence-open ( lim -- lim_outer lim_inner )
341 read-tag check-sequence read-length-open-elt ;
343 \ Read the next element as a BIT STRING with no ignore bits, and open
345 : read-bits-open ( lim -- lim_outer lim_inner )
346 read-tag 0x03 check-tag-primitive
347 read-length-open-elt
378 \ Read a "small value". This assumes that the tag has just been read
383 \ Either way, the element is fully read.
384 : read-small-value ( lim -- lim bool )
385 read-length-open-elt
388 addr-pad 1+ read-blob
391 \ Read an OID as a "small value" (tag, length and value). A boolean
394 : read-OID ( lim -- lim bool )
395 read-tag 0x06 check-tag-primitive read-small-value ;
397 \ Read a UTF-8 code point. On error, return 0. Reading a code point of
399 : read-UTF8 ( lim -- lim val )
404 dup 0xE0 < uf 0x1F and 1 read-UTF8-next 0x80 0x7FF enduf
405 dup 0xF0 < uf 0x0F and 2 read-UTF8-next 0x800 0xFFFF enduf
406 dup 0xF8 < uf 0x07 and 3 read-UTF8-next 0x10000 0x10FFFF enduf
412 \ Read n subsequent bytes to complete the provided first byte. The final
415 : read-UTF8-next ( lim val n -- lim val val )
418 read-UTF8-chunk
423 \ Read one byte, that should be a trailing UTF-8 byte, and complement the
425 : read-UTF8-chunk ( lim val -- lim val )
444 \ Read a UTF-16 code point (big-endian). Returned value is 0 on error.
445 : read-UTF16BE ( lim -- lim val )
457 \ Read a UTF-16 code point (little-endian). Returned value is 0 on error.
458 : read-UTF16LE ( lim -- lim val )
512 \ Read a string value into the pad; this function checks that the source
516 : read-value-UTF8 ( lim -- lim bool )
517 read-length-open-elt
520 read-UTF8 dup ifnot drop skip-close-elt 0 ret then
530 : read-value-UTF16 ( lim -- lim bool )
531 read-length-open-elt
534 read-UTF16BE dup 0xFFFE = if
538 read-UTF16LE dup ifnot drop skip-close-elt 0 ret then
547 read-UTF16BE dup ifnot drop skip-close-elt 0 ret then
556 : read-value-latin1 ( lim -- lim bool )
557 read-length-open-elt
565 \ Read a value and interpret it as an INTEGER or ENUMERATED value. If
567 \ is reported. This function assumes that the tag has just been read
569 : read-small-int-value ( lim -- lim x )
570 read-length-open-elt
614 \ Read two ASCII digits and return the value in the 0..99 range. An
616 : read-dec2 ( lim -- lim x )
619 \ Read two ASCII digits and check that the value is in the provided
621 : read-dec2-range ( lim min max -- lim x )
623 read-dec2 dup min max between? ifnot ERR_X509_BAD_TIME fail then ;
632 \ Read a date (UTCTime or GeneralizedTime). The date value is converted
638 : read-date ( lim -- lim days seconds )
639 \ Read tag; must be UTCTime or GeneralizedTime. Year count is
641 read-tag
645 read-length-open-elt
654 read-dec2
656 100 * >x read-dec2 x +
665 1 12 read-dec2-range
674 1 swap read-dec2-range
682 0 23 read-dec2-range 3600 * >seconds
683 0 59 read-dec2-range 60 * seconds + >seconds
684 0 60 read-dec2-range seconds + >seconds
701 \ Read an INTEGER (tag, length and value). The INTEGER is supposed to be
705 : read-integer ( lim addr len -- lim dlen )
706 rot read-tag 0x02 check-tag-primitive -rot
707 read-integer-next ;
709 \ Identical to read-integer, but the tag has already been read and checked.
710 : read-integer-next ( lim addr len -- lim dlen )
712 read-length-open-elt
713 \ Read first byte; sign bit must be 0.
729 \ Read a BOOLEAN value. This should be called immediately after reading
731 : read-boolean ( lim constructed value -- lim bool )
733 read-length 1 <> if ERR_X509_BAD_BOOLEAN fail then
736 \ Identify an elliptic curve: read the OID, then check it against the
738 : read-curve-ID ( lim -- lim curve )
739 read-OID ifnot ERR_X509_UNSUPPORTED fail then