private void STEP2(int A, int B, int MAC, int MIC, short[] LAR, int index) { short temp = 0; temp = Add.GSM_MULT((short) A, LAR[index]); temp = Add.GSM_ADD(temp, (short) B); temp = Add.GSM_ADD(temp, (short) 256); temp = Add.SASR(temp, 9); LAR[index] = (short) (temp > MAC ? MAC - MIC : (temp < MIC ? 0 : temp - MIC)); }
private void Reflection_coefficients(short[] r /* 0...7 OUT */) throws IllegalArgumentException { short temp = 0; int ltmp = 0; int r_index = 0; short[] ACF = new short[9]; /* 0..8 */ short[] P = new short[9]; /* 0..8 */ short[] K = new short[9]; /* 2..8 */ /* Schur recursion with 16 bits arithmetic. */ if (L_ACF[0] == 0) { /* everything is the same. */ for (int i = 0; i < 8; i++) { r[i] = 0; } return; } if (L_ACF[0] == 0) { throw new IllegalArgumentException( "Reflection_coefficients: L_ACF[0] = " + L_ACF[0] + " should not = 0."); } temp = Add.gsm_norm(L_ACF[0]); if (!(temp >= 0 && temp < 32)) { throw new IllegalArgumentException( "Reflection_coefficients: temp = " + temp + " should be >= 0 and < 32."); } /* ? overflow ? */ for (int i = 0; i <= 8; i++) { ACF[i] = Add.SASR(L_ACF[i] << temp, 16); } /* Initialize array P[..] and K[..] for the recursion. */ System.arraycopy(ACF, 0, K, 0, 7); System.arraycopy(ACF, 0, P, 0, 8); /* CoreCompute reflection coefficients */ for (int n = 1; n <= 8; n++, r_index++) { temp = P[1]; temp = Add.GSM_ABS(temp); if (P[0] < temp) { for (int i = n; i < 8; i++) { r[i] = 0; } return; } r[r_index] = Add.gsm_div(temp, P[0]); if (!(r[r_index] >= 0)) { throw new IllegalArgumentException( "Reflection_coefficients: r[" + r_index + "] = " + r[r_index] + " should be >= 0"); } if (P[1] > 0) { /* r[n] = sub(0, r[n]) */ r[r_index] = (short) (-(r[r_index])); } if (r[r_index] == Gsm_Def.MIN_WORD) { throw new IllegalArgumentException( "Reflection_coefficients: r[" + r_index + "] = " + r[r_index] + " should not be " + Gsm_Def.MIN_WORD); } if (n == 8) { return; } /* Schur recursion */ temp = Add.GSM_MULT_R(P[1], r[r_index]); P[0] = Add.GSM_ADD(P[0], temp); for (int m = 1; m <= 8 - n; m++) { temp = Add.GSM_MULT_R(K[m], r[r_index]); P[m] = Add.GSM_ADD(P[m + 1], temp); temp = Add.GSM_MULT_R(P[m + 1], r[r_index]); K[m] = Add.GSM_ADD(K[m], temp); } } }