CALL des_ecb_lm_enc(input->buffer, sessionkey[keyindex], output->buffer) INCREMENT input->buffer by blocklen INCREMENT output->buffer by blocklen INCREMENT output->length by blocklen SET keyindex to AdvanceKey(keyindex) DECREMENT remaining by blocklen ENDWHILE IF (remaining > 0) THEN // zero pad the last block. SET bytes in buffer to 0 COPY remaining from input->buffer to buffer CALL des_ecb_lm_enc(buffer, sessionkey[keyindex], output->buffer) INCREMENT output->length by blocklen ENDIF } decrypt_secret(input : LSA_UNICODE_STRING, sessionkey : byte[16], output : LSA_UNICODE_STRING) { LET keyindex be 0 LET blocklen be 8 // Check version, get clear length. CALL des_ecb_lm_dec(input->buffer, sessionkey[keyindex], output->buffer) LET outputlength be output[0] LET version be output[1] IF (version 1) THEN // version ≠ FAIL ENDIF INCREMENT input->buffer by blocklen SET keyindex to AdvanceKey(keyindex) LET remaining be outputlength WHILE remaining > blocklen CALL des_ecb_lm_dec(input->buffer, sessionkey[keyindex], output->buffer) INCREMENT input->buffer by blocklen INCREMENT output->buffer by blocklen SET keyindex to AdvanceKey(keyindex) DECREMENT remaining by blocklen ENDWHILE IF (remaining > 0) THEN CALL des_ecb_lm_dec(input->buffer, sessionkey[keyindex], output->buffer) ENDIF SET output->length to outputlength } AdvanceKey(pos : ULONG)
CALL des_ecb_lm_enc(input->buffer, sessionkey[keyindex], output->buffer) INCREMENT input->buffer by blocklen INCREMENT output->buffer by blocklen INCREMENT output->length by blocklen SET keyindex to AdvanceKey(keyindex) DECREMENT remaining by blocklen ENDWHILE IF (remaining > 0) THEN // zero pad the last block. SET bytes in buffer to 0 COPY remaining from input->buffer to buffer CALL des_ecb_lm_enc(buffer, sessionkey[keyindex], output->buffer) INCREMENT output->length by blocklen ENDIF } decrypt_secret(input : LSA_UNICODE_STRING, sessionkey : byte[16], output : LSA_UNICODE_STRING) { LET keyindex be 0 LET blocklen be 8 // Check version, get clear length. CALL des_ecb_lm_dec(input->buffer, sessionkey[keyindex], output->buffer) LET outputlength be output[0] LET version be output[1] IF (version ≠ 1) THEN // version FAIL ENDIF INCREMENT input->buffer by blocklen SET keyindex to AdvanceKey(keyindex) LET remaining be outputlength WHILE remaining > blocklen CALL des_ecb_lm_dec(input->buffer, sessionkey[keyindex], output->buffer) INCREMENT input->buffer by blocklen INCREMENT output->buffer by blocklen SET keyindex to AdvanceKey(keyindex) DECREMENT remaining by blocklen ENDWHILE IF (remaining > 0) THEN CALL des_ecb_lm_dec(input->buffer, sessionkey[keyindex], output->buffer) ENDIF SET output->length to outputlength } AdvanceKey(pos : ULONG)
%5BMS-LSAD%5D-160714.docx