2.4.4.2 Encode Nulls

The Password Hash stores Key and PasswordHash with null bytes removed. The fields are encoded by replacing 0x00 bytes with 0x01 and setting a bit on the bit-fields GrbitKey and GrbitHashNull, respectively.

This algorithm accepts the following as parameters:

InputBytes (variable): An input array of bytes to be encoded.

GrbitNull (variable): An output array of bits specifying null bytes in InputBytes.

EncodedBytes (variable): An output array of encoded bytes.

Encoding is computed by the following pseudocode:

 FOR each Byte IN InputBytes:
  
    IF Byte EQUALS 0x00 THEN:
  
       APPEND EncodedBytes WITH 0x01.
  
       APPEND GrbitNull WITH one bit set to FALSE.
  
    ELSE:
  
       APPEND EncodedBytes WITH Byte.
  
       APPEND GrbitNull WITH one bit set to TRUE.
  
    END IF
  
 END FOR