Modification Detection Code calculation

The Modification Detection Code (MDC) calculation method defines a one-way cryptographic function.

A one-way cryptographic function is a function in which it is easy to compute the input into output (a digest) but very difficult to compute the output into input. MDC uses DES encryption only and a default key of X'5252 5252 5252 5252 2525 2525 2525 2525'.

The MDC Generate verb supports four versions of the MDC calculation method that you specify by using one of the keywords shown in Table 1. All versions use the MDC-1 calculation.
Table 1. Versions of the MDC calculation method
Keyword Version of the MDC calculation
MDC-2, PADMDC-2 Specifies two encipherments for each 8-byte input data block. These versions use the MDC-2 calculation procedure described in Table 2.
MDC-4, PADMDC-4 Specifies four encipherments for each 8-byte input data block. These versions use the MDC-4 calculation procedure described in Table 2.
When the keywords PADMDC-2 and PADMDC-4 are used, the supplied text is always padded as follows:
  • If the total supplied text is less than 16 bytes in length, pad bytes are appended to make the text length equal to 16 bytes. A length of zero is allowed.
  • If the total supplied text is a minimum of 16 bytes in length, pad bytes are appended to make the text length equal to the next-higher multiple of eight bytes. One or more pad bytes are always added.
  • All appended pad bytes, other than the last pad byte, are set to X'FF'.
  • The last pad byte is set to a binary value equal to the count of all appended pad bytes (X'01' - X'10').
Use the resulting pad text in the Table 2. The MDC Generate verb uses these MDC calculation methods. See MDC Generate (CSNBMDG) for more information.
Table 2. MDC calculation procedures
Calculation Procedure
MDC-1
MDC-1(KD1, KD2, IN1, IN2, OUT1, OUT2);
 Set KD1mod := set KD1 bit 1 to B'1' and bit 2 to B'0' (bits 0-7)
 Set KD2mod := set KD2 bit 1 to B'0' and bit 2 to B'1' (bits 0-7)
 Set F1 := IN1 XOR eKD1mod(IN1)
 Set F2 := IN2 XOR eKD2mod(IN2)
 Set OUT1 := (bits 0..31 of F1) || (bits 32..63 of F2)
 Set OUT2 := (bits 0..31 of F2) || (bits 32..63 of F1)
End procedure
MDC-2
MDC-2(n, text, KEY1, KEY2, MDC);
 For i := 1, 2, ..., n do
  Call MDC-1(KEY1, KEY2, T8<i>, T8<i>, OUT1, OUT2)
  Set KEY1 := OUT1
  Set KEY2 := OUT2
 End do
 Set output MDC := (KEY1 || KEY2)
End procedure
MDC-4
MDC-4(n, text, KEY1, KEY2, MDC);
 For i := 1, 2, ..., n do
  Call MDC-1(KEY1, KEY2, T8<i>, T8<i>, OUT1, OUT2)
  Set KEY1int := OUT1
  Set KEY2int := OUT2
  Call MDC-1(KEY1int, KEY2int, KEY2, KEY1, OUT1, OUT2)
  Set KEY1 := OUT1
  Set KEY2 := OUT2
 End do
 Set output MDC := (KEY1 || KEY2)
End procedure
Notation:
eK(X)
DES encryption of plaintext X using key K
||
Concatenation operation
XOR
Exclusive-OR operation
:=
Assignment operation
T8<1>
First 8-byte block of text
T8<2>
Second 8-byte block of text
KD1, KD2
64-bit quantities
IN1, IN2
64-bit quantities
OUT1, OUT2
64-bit quantities
n
Number of 8-byte blocks