libtom / libtomcrypt

LibTomCrypt is a fairly comprehensive, modular and portable cryptographic toolkit that provides developers with a vast array of well known published block ciphers, one-way hash functions, chaining modes, pseudo-random number generators, public key cryptography and a plethora of other routines.
https://www.libtom.net
Other
1.55k stars 457 forks source link

Add new utf8 test-vector, update comments explaining utf8 decoding #558

Closed jamuir closed 3 years ago

jamuir commented 3 years ago

Description: Minor changes to help test and clarify the way utf8 strings are decoded. This originated from my misunderstanding of the fix for issue #507. The new test-vector uses two bytes to encode each wide-char.

The utf8 format is described here:

https://tools.ietf.org/html/rfc3629#section-3

Testing:

  $ make clean
  $ make CFLAGS="-DUSE_LTM -DLTM_DESC -I../libtommath" EXTRALIBS="../libtommath/libtommath.a" test
  $ ./test

You can confirm that the new utf8 test data is correct using python:

  >>> s="\xD7\xA9\xD7\x9C\xD7\x95\xD7\x9D"
  >>> s.decode("utf-8")
  u'\u05e9\u05dc\u05d5\u05dd'

Checklist

jamuir commented 3 years ago

@sjaeckel : please take another look and let me know what you think.