• Heikki Linnakangas's avatar
    Use SASLprep to normalize passwords for SCRAM authentication. · 60f11b87
    Heikki Linnakangas authored
    An important step of SASLprep normalization, is to convert the string to
    Unicode normalization form NFKC. Unicode normalization requires a fairly
    large table of character decompositions, which is generated from data
    published by the Unicode consortium. The script to generate the table is
    put in src/common/unicode, as well test code for the normalization.
    A pre-generated version of the tables is included in src/include/common,
    so you don't need the code in src/common/unicode to build PostgreSQL, only
    if you wish to modify the normalization tables.
    
    The SASLprep implementation depends on the UTF-8 functions from
    src/backend/utils/mb/wchar.c. So to use it, you must also compile and link
    that. That doesn't change anything for the current users of these
    functions, the backend and libpq, as they both already link with wchar.o.
    It would be good to move those functions into a separate file in
    src/commmon, but I'll leave that for another day.
    
    No documentation changes included, because there is no details on the
    SCRAM mechanism in the docs anyway. An overview on that in the protocol
    specification would probably be good, even though SCRAM is documented in
    detail in RFC5802. I'll write that as a separate patch. An important thing
    to mention there is that we apply SASLprep even on invalid UTF-8 strings,
    to support other encodings.
    
    Patch by Michael Paquier and me.
    
    Discussion: https://www.postgresql.org/message-id/CAB7nPqSByyEmAVLtEf1KxTRh=PWNKiWKEKQR=e1yGehz=wbymQ@mail.gmail.com
    60f11b87
saslprep.h 844 Bytes