Class: OracleEbsAuthentication::Security

Inherits:
Object
  • Object
show all
Defined in:
lib/oracle_ebs_authentication/security.rb

Overview

public class eBusinessSuiteSecurity {

Constant Summary collapse

J =
2
K =
4
L =
[
    256, 0x2080100, 0x2080000, 0x42000100, 0x80000, 256, 0x40000000,
    0x2080000, 0x40080100, 0x80000,
    0x2000100, 0x40080100, 0x42000100, 0x42080000, 0x80100, 0x40000000,
    0x2000000, 0x40080000, 0x40080000, 0,
    0x40000100, 0x42080100, 0x42080100, 0x2000100, 0x42080000, 0x40000100, 0,
    0x42000000, 0x2080100, 0x2000000,
    0x42000000, 0x80100, 0x80000, 0x42000100, 256, 0x2000000, 0x40000000,
    0x2080000, 0x42000100, 0x40080100,
    0x2000100, 0x40000000, 0x42080000, 0x2080100, 0x40080100, 256, 0x2000000,
    0x42080000, 0x42080100, 0x80100,
    0x42000000, 0x42080100, 0x2080000, 0, 0x40080000, 0x42000000, 0x80100,
    0x2000100, 0x40000100, 0x80000,
    0, 0x40080000, 0x2080100, 0x40000100
]
M =
2
N =
[
    0x802001, 8321, 8321, 128, 0x802080, 0x800081, 0x800001, 8193, 0,
    0x802000,
    0x802000, 0x802081, 129, 0, 0x800080, 0x800001, 1, 8192, 0x800000,
    0x802001,
    128, 0x800000, 8193, 8320, 0x800081, 1, 8320, 0x800080, 8192, 0x802080,
    0x802081, 129, 0x800080, 0x800001, 0x802000, 0x802081, 129, 0, 0,
    0x802000,
    8320, 0x800080, 0x800081, 1, 0x802001, 8321, 8321, 128, 0x802081, 129,
    1, 8192, 0x800001, 8193, 0x802080, 0x800081, 8193, 8320, 0x800000,
    0x802001,
    128, 0x800000, 8192, 0x802080
]
O =
1
P =
[
    520, 0x8020200, 0, 0x8020008, 0x8000200, 0, 0x20208, 0x8000200, 0x20008,
    0x8000008,
    0x8000008, 0x20000, 0x8020208, 0x20008, 0x8020000, 520, 0x8000000, 8,
    0x8020200, 512,
    0x20200, 0x8020000, 0x8020008, 0x20208, 0x8000208, 0x20200, 0x20000,
    0x8000208, 8, 0x8020208,
    512, 0x8000000, 0x8020200, 0x8000000, 0x20008, 520, 0x20000, 0x8020200,
    0x8000200, 0,
    512, 0x20008, 0x8020208, 0x8000200, 0x8000008, 512, 0, 0x8020008,
    0x8000208, 0x20000,
    0x8000000, 0x8020208, 8, 0x20208, 0x20200, 0x8000008, 0x8020000,
    0x8000208, 520, 0x8020000,
    0x20208, 8, 0x8020008, 0x20200
]
Q =
0x8f1bbcdc
R =
[
    0x80108020, 0x80008000, 32768, 0x108020, 0x100000, 32, 0x80100020,
    0x80008020, 0x80000020, 0x80108020,
    0x80108000, 0x80000000, 0x80008000, 0x100000, 32, 0x80100020, 0x108000,
    0x100020, 0x80008020, 0,
    0x80000000, 32768, 0x108020, 0x80100000, 0x100020, 0x80000020, 0,
    0x108000, 32800, 0x80108000,
    0x80100000, 32800, 0, 0x108020, 0x80100020, 0x100000, 0x80008020,
    0x80100000, 0x80108000, 32768,
    0x80100000, 0x80008000, 32, 0x80108020, 0x108020, 32, 32768, 0x80000000,
    32800, 0x80108000,
    0x100000, 0x80000020, 0x100020, 0x80008020, 0x80000020, 0x100020,
    0x108000, 0, 0x80008000, 32800,
    0x80000000, 0x80100020, 0x80108020, 0x108000
]
S =
[
    13, 16, 10, 23, 0, 4, 2, 27, 14, 5,
    20, 9, 22, 18, 11, 3, 25, 7, 15, 6,
    26, 19, 12, 1, 40, 51, 30, 36, 46, 54,
    29, 39, 50, 44, 32, 47, 43, 48, 38, 55,
    33, 52, 45, 41, 49, 35, 28, 31
]
T =
[
    0x1010400, 0, 0x10000, 0x1010404, 0x1010004, 0x10404, 4, 0x10000, 1024,
    0x1010400,
    0x1010404, 1024, 0x1000404, 0x1010004, 0x1000000, 4, 1028, 0x1000400,
    0x1000400, 0x10400,
    0x10400, 0x1010000, 0x1010000, 0x1000404, 0x10004, 0x1000004, 0x1000004,
    0x10004, 0, 1028,
    0x10404, 0x1000000, 0x10000, 0x1010404, 4, 0x1010000, 0x1010400,
    0x1000000, 0x1000000, 1024,
    0x1010004, 0x10000, 0x10400, 0x1000004, 1024, 4, 0x1000404, 0x10404,
    0x1010404, 0x10004,
    0x1010000, 0x1000404, 0x1000004, 1028, 0x10404, 0x1010400, 1028,
    0x1000400, 0x1000400, 0,
    0x10004, 0x10400, 0, 0x1010004
]
U =
8
V =
[
    56, 48, 40, 32, 24, 16, 8, 0, 57, 49,
    41, 33, 25, 17, 9, 1, 58, 50, 42, 34,
    26, 18, 10, 2, 59, 51, 43, 35, 62, 54,
    46, 38, 30, 22, 14, 6, 61, 53, 45, 37,
    29, 21, 13, 5, 60, 52, 44, 36, 28, 20,
    12, 4, 27, 19, 11, 3
]
W =
[
    0x800000, 0x400000, 0x200000, 0x100000, 0x80000, 0x40000, 0x20000,
    0x10000, 32768, 16384,
    8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16,
    8, 4, 2, 1
]
X =
0x6ed9eba1
Y =
8
Z =
100
Ba =
32
Bb =
[
    1, 2, 4, 6, 8, 10, 12, 14, 15, 17,
    19, 21, 23, 25, 27, 28
]
Bc =
30
Bd =
"ZG"
Be =
false
Bf =
0x5a827999
Bg =
[
    0x10001040, 4096, 0x40000, 0x10041040, 0x10000000, 0x10001040, 64,
    0x10000000, 0x40040, 0x10040000,
    0x10041040, 0x41000, 0x10041000, 0x41040, 4096, 64, 0x10040000,
    0x10000040, 0x10001000, 4160,
    0x41000, 0x40040, 0x10040040, 0x10041000, 4160, 0, 0, 0x10040040,
    0x10000040, 0x10001000,
    0x41040, 0x40000, 0x41040, 0x40000, 0x10041000, 4096, 64, 0x10040040,
    4096, 0x41040,
    0x10001000, 64, 0x10000040, 0x10040000, 0x10040040, 0x10000000, 0x40000,
    0x10001040, 0, 0x10041040,
    0x40040, 0x10000040, 0x10040000, 0x10001000, 0x10001040, 0, 0x10041040,
    0x41000, 0x41000, 4160,
    4160, 0x40040, 0x10000000, 0x10041000
]
Bh =
0xca62c1d6
Bi =
[
    -128, 64, 32, 16, 8, 4, 2, 1
]
Bj =
[
    0x200000, 0x4200002, 0x4000802, 0, 2048, 0x4000802, 0x200802, 0x4200800,
    0x4200802, 0x200000,
    0, 0x4000002, 2, 0x4000000, 0x4200002, 2050, 0x4000800, 0x200802,
    0x200002, 0x4000800,
    0x4000002, 0x4200000, 0x4200800, 0x200002, 0x4200000, 2048, 2050,
    0x4200802, 0x200800, 2,
    0x4000000, 0x200800, 0x4000000, 0x200800, 0x200000, 0x4000802, 0x4000802,
    0x4200002, 0x4200002, 2,
    0x200002, 0x4000000, 0x4000800, 0x200000, 0x4200800, 2050, 0x200802,
    0x4200800, 2050, 0x4000002,
    0x4200802, 0x4200000, 0x200800, 0, 2, 0x4200802, 0, 0x200802, 0x4200000,
    2048,
    0x4000002, 0x4000800, 2048, 0x200002
]
Bk =
"ZG_ENCRYPT_FAILED_"
Bl =
15
Bm =
[
    0x20000010, 0x20400000, 16384, 0x20404010, 0x20400000, 16, 0x20404010,
    0x400000, 0x20004000, 0x404010,
    0x400000, 0x20000010, 0x400010, 0x20004000, 0x20000000, 16400, 0,
    0x400010, 0x20004010, 16384,
    0x404000, 0x20004010, 16, 0x20400010, 0x20400010, 0, 0x404010, 0x20404000,
    16400, 0x404000,
    0x20404000, 0x20000000, 0x20004000, 16, 0x20400010, 0x404000, 0x20404010,
    0x400000, 16400, 0x20000010,
    0x400000, 0x20004000, 0x20000000, 16400, 0x20000010, 0x20404010, 0x404000,
    0x20400000, 0x404010, 0x20404000,
    0, 0x20400010, 16, 16384, 0x20400000, 0x404010, 16384, 0x400010,
    0x20004010, 0,
    0x20404000, 0x20000000, 0x400010, 0x20004010
]

Instance Method Summary collapse

Constructor Details

#initializeSecurity

public eBusinessSuiteSecurity() { }



18
19
# File 'lib/oracle_ebs_authentication/security.rb', line 18

def initialize
end

Instance Method Details

#a(abyte0, i1) ⇒ Object

private static int[] a(byte abyte0[], int i1) {



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/oracle_ebs_authentication/security.rb', line 29

def a(abyte0, i1)
#  int ai[] = new int[16];
  ai = [nil]*16
#  int ai1[] = new int[5];
  ai1 = [nil]*5
#  u(ai1, null);
  u(ai1, nil)
#  int l1 = ai.length;
  l1 = ai.length
#  int k1 = 0;
  k1 = 0
#  int j2 = 0;
  j2 = 0
#  int j1;
#  for (j1 = 0; j1 < (i1 & -4); j1 += 4) {
  j1 = 0
  while j1 < (i1 & -4)
#    ai[k1] = abyte0[j2] | abyte0[j2 + 1] << 8 | abyte0[j2 + 2] << 16 |
#        abyte0[j2 + 3] << 24;
    ai[k1] = (abyte0[j2] | abyte0[j2 + 1] << 8 | abyte0[j2 + 2] << 16 |
        abyte0[j2 + 3] << 24) & 0xffffffff
#    if (++k1 == l1) {
#      u(ai1, ai);
#      k1 = 0;
#    }
    k1 +=1
    if (k1 == l1)
      u(ai1, ai)
      k1 = 0
    end
#    j2 += 4;
    j2 += 4
#  }
    j1 += 4
  end
#
#  j1 = i1 - j1;
  j1 = i1 - j1
#  if (j1 == 1) {
#    ai[k1] = abyte0[j2] & 0xff | 0x8000;
#  }
  if (j1 == 1)
    ai[k1] = abyte0[j2] & 0xff | 0x8000
#  else
#  if (j1 == 2) {
#    ai[k1] = abyte0[j2] | abyte0[j2 + 1] << 8 | 0x800000;
#  }
  elsif (j1 == 2)
    ai[k1] = (abyte0[j2] | abyte0[j2 + 1] << 8 | 0x800000) & 0xffffffff
#  else
#  if (j1 == 3) {
#    ai[k1] = abyte0[j2] | abyte0[j2 + 1] << 8 | abyte0[j2 + 2] << 16 |
#        0x80000000;
#  }
  elsif (j1 == 3)
    ai[k1] = (abyte0[j2] | abyte0[j2 + 1] << 8 | abyte0[j2 + 2] << 16 | 0x80000000) & 0xffffffff
#  else {
#    ai[k1] = 128;
#  }
  else
    ai[k1] = 128
  end
#  if (++k1 >= l1 - 2) {
#    while (k1 < l1) {
#      ai[k1++] = 0;
#    }
#    u(ai1, ai);
#    k1 = 0;
#  }
  k1 += 1
  if (k1 >= l1 - 2)
    while (k1 < l1)
      ai[k1] = 0
      k1 += 1
    end
    u(ai1,ai)
    k1 = 0
  end
#  while (k1 < l1 - 2) {
#    ai[k1++] = 0;
#  }
  while (k1 < l1 - 2)
    ai[k1] = 0
    k1 += 1
  end
#  int i2 = i1;
  i2 = i1
#  ai[k1++] = i2 >> 29 & 7;
  ai[k1] = i2 >> 29 & 7
  k1 += 1
#  ai[k1] = i2 << 3;
  ai[k1] = (i2 << 3) & 0xffffffff
#  u(ai1, ai);
  u(ai1, ai)
#  return ai1;
  return ai1
#}
end

#a_(ac) ⇒ Object

private static byte[] A(char ac[]) {



1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
# File 'lib/oracle_ebs_authentication/security.rb', line 1499

def a_(ac)
  # RSI: if we receive String then return the same value (as it should already be in UTF-8)
  return ac if ac.is_a? String
#   byte abyte0[] = new byte[ac.length * 3];
  abyte0 = "\0"*(ac.length * 3)
#   int i1 = 0;
  i1 = 0
#   boolean flag = false;
  flag = false
#   for (int j1 = 0; j1 < ac.length; j1++) {
  for j1 in 0...ac.length
#     char c1 = ac[j1];
    c1 = ac[j1]
#     if (c1 >= 0 && c1 <= '\177') {
#       abyte0[i1++] = (byte) (c1 & 0x7f);
#     }
    if (c1 >= 0 && c1 <= 0177)
      abyte0[i1] = (c1 & 0x7f)
      i1 += 1
#     else
#     if (c1 >= '\200' && c1 <= '\u07FF') {
#       abyte0[i1++] = (byte) ( (c1 & 0x7c0) >> 6 | 0xc0);
#       abyte0[i1++] = (byte) (c1 & 0x3f | 0x80);
#     }
    elsif (c1 >= 0200 && c1 <= 0x07FF)
      abyte0[i1] = ( (c1 & 0x7c0) >> 6 | 0xc0)
      i1 += 1
      abyte0[i1] = (c1 & 0x3f | 0x80)
      i1 += 1
#     else
#     if (c1 >= '\u0800' && c1 <= '\uFFFF') {
#       abyte0[i1++] = (byte) ( (c1 & 0xf000) >> 12 | 0xe0);
#       abyte0[i1++] = (byte) ( (c1 & 0xfc0) >> 6 | 0x80);
#       abyte0[i1++] = (byte) (c1 & 0x3f | 0x80);
#     }
    elsif (c1 >= 0x0800 && c1 <= 0xFFFF)
      abyte0[i1] = ( (c1 & 0xf000) >> 12 | 0xe0)
      i1 += 1
      abyte0[i1] = ( (c1 & 0xfc0) >> 6 | 0x80)
      i1 += 1
      abyte0[i1] = (c1 & 0x3f | 0x80)
      i1 += 1
    end
#   }
  end
# 
#   byte abyte1[] = new byte[i1];
  abyte1 = "\0"*i1
#   System.arraycopy(abyte0, 0, abyte1, 0, i1);
  abyte1[0, i1] = abyte0[0, i1]
#   return abyte1;
  abyte1
# }
end

#b_(abyte0, abyte1, abyte2, i1) ⇒ Object

private static void B(byte abyte0[], byte abyte1[], byte abyte2[], int i1) {



1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
# File 'lib/oracle_ebs_authentication/security.rb', line 1555

def b_(abyte0, abyte1, abyte2, i1)
#   if (abyte0 == null) {
  if (abyte0 == nil)
#     if (i1 > 0 && abyte1 != null && abyte2 != null) {
    if (i1 > 0 && abyte1 != nil && abyte2 != nil)
#       for (int j1 = 0; j1 < i1; j1++) {
#         abyte2[j1] = abyte1[j1];
# 
#       }
      for j1 in 0...i1
        abyte2[j1] = abyte1[j1]
      end
#       return;
      return
#     }
    end
#   }
#   else {
#     if (abyte2 == null) {
  else
    if (abyte2 == nil)
#       for (int k1 = 0; k1 < 256; k1++) {
#         abyte0[k1] = (byte) k1;
# 
#       }
      for k1 in 0...256
        abyte0[k1] = k1
      end
#       if (abyte1 != null && i1 > 0) {
      if (abyte1 != nil && i1 > 0)
#         int j2 = 0;
        j2 = 0
#         int l2 = 0;
        l2 = 0
#         for (int l1 = 0; l1 < 256; l1++) {
#           int j3 = (new Byte(abyte0[l1])).intValue() & 0xff;
#           j2 = j2 + j3 + ( (new Byte(abyte1[l2])).intValue() & 0xff) & 0xff;
#           abyte0[l1] = abyte0[j2];
#           abyte0[j2] = (new Integer(j3 & 0xff)).byteValue();
#           l2 = (l2 + 1) % i1;
#         }
        for l1 in 0...256
          j3 = abyte0[l1] & 0xff
          j2 = j2 + j3 + ( abyte1[l2] & 0xff) & 0xff
          abyte0[l1] = abyte0[j2]
          abyte0[j2] = j3 & 0xff
          l2 = (l2 + 1) % i1
        end
# 
#       }
      end
#       abyte0[256] = 0;
      abyte0[256] = 0
#       abyte0[257] = 0;
      abyte0[257] = 0
#       return;
      return
#     }
    end
#     int i2 = (new Byte(abyte0[256])).intValue() & 0xff;
    i2 = abyte0[256] & 0xff
#     int k2 = (new Byte(abyte0[257])).intValue() & 0xff;
    k2 = abyte0[257] & 0xff
#     for (int i3 = 0; i3 < i1; i3++) {
    for i3 in 0...i1
#       i2 = i2 + 1 & 0xff;
      i2 = i2 + 1 & 0xff
#       int k3 = (new Byte(abyte0[i2])).intValue() & 0xff;
      k3 = abyte0[i2] & 0xff
#       k2 = k2 + k3 & 0xff;
      k2 = k2 + k3 & 0xff
#       abyte0[i2] = abyte0[k2];
      abyte0[i2] = abyte0[k2]
#       abyte0[k2] = (new Integer(k3 & 0xff)).byteValue();
      abyte0[k2] = k3 & 0xff
#       k3 += (new Byte(abyte0[i2])).intValue() & 0xff;
      k3 += abyte0[i2] & 0xff
#       abyte2[i3] = (byte) (abyte1[i3] ^ abyte0[k3 & 0xff]);
      abyte2[i3] = (abyte1[i3] ^ abyte0[k3 & 0xff])
#       new String("");
      ""
#     }
    end
# 
#     abyte0[256] = (byte) (i2 & 0xff);
    abyte0[256] = (i2 & 0xff)
#     abyte0[257] = (byte) (k2 & 0xff);
    abyte0[257] = (k2 & 0xff)
#   }
  end
# }
end

#c(ai) ⇒ Object

private static void c(int ai[])

ai[4] = j(ai[0], 5) + s(ai[1], ai[2], ai[3]) + ai[4] + ai[5] + 0x8f1bbcdc;
ai[2] = j(ai[1], 30);



267
268
269
270
# File 'lib/oracle_ebs_authentication/security.rb', line 267

def c(ai)
  ai[4] = j(ai[0], 5) + s(ai[1], ai[2], ai[3]) + ai[4] + ai[5] + 0x8f1bbcdc
  ai[2] = j(ai[1], 30)
end

#c_(ai) ⇒ Object

private static int[] C(int ai[]) {



1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
# File 'lib/oracle_ebs_authentication/security.rb', line 1690

def c_(ai)
#   int ai1[] = new int[32];
  ai1 = [nil]*32
#   int ai2[] = ai;
  ai2 = ai
#   int i1 = 0;
  i1 = 0
#   boolean flag = false;
  flag = false
#   int k1 = 0;
  k1 = 0
#   int l1 = 0;
  l1 = 0
#   while (i1 < 16) {
  while (i1 < 16)
#     int j1 = k1++;
    j1 = k1
    k1 += 1
#     ai1[l1] = (ai2[j1] & 0xfc0000) << 6;
    ai1[l1] = (ai2[j1] & 0xfc0000) << 6
#     ai1[l1] |= (ai2[j1] & 0xfc0) << 10;
    ai1[l1] |= (ai2[j1] & 0xfc0) << 10
#     ai1[l1] |= (ai[k1] & 0xfc0000) >> 10;
    ai1[l1] |= (ai[k1] & 0xfc0000) >> 10
#     ai1[l1] |= (ai[k1] & 0xfc0) >> 6;
    ai1[l1] |= (ai[k1] & 0xfc0) >> 6
#     l1++;
    l1 += 1
#     ai1[l1] = (ai2[j1] & 0x3f000) << 12;
    ai1[l1] = (ai2[j1] & 0x3f000) << 12
#     ai1[l1] |= (ai2[j1] & 0x3f) << 16;
    ai1[l1] |= (ai2[j1] & 0x3f) << 16
#     ai1[l1] |= (ai[k1] & 0x3f000) >> 4;
    ai1[l1] |= (ai[k1] & 0x3f000) >> 4
#     ai1[l1] |= ai[k1] & 0x3f;
    ai1[l1] |= ai[k1] & 0x3f
#     l1++;
    l1 += 1
#     i1++;
    i1 += 1
#     k1++;
    k1 += 1
#   }
  end
#   return ai1;
  return ai1
# }
end

#check(s1, s2, flag) ⇒ Object

static boolean check(String s1, String s2, boolean flag) {



1649
1650
1651
1652
# File 'lib/oracle_ebs_authentication/security.rb', line 1649

def check(s1, s2, flag)
  return true if decrypt(s1, s2, flag)
  false
end

#control(s1, s2, i1) ⇒ Object

static String control(String s1, String s2, int i1)

return newControl(s1, s2, 0, i1);



24
25
26
# File 'lib/oracle_ebs_authentication/security.rb', line 24

def control(s1, i1, s2)
  return new_control(s1, s2, i1, 0)
end

#d(abyte0, ai) ⇒ Object

private static void d(byte abyte0[], int ai[])

int ai1[] = new int[2];
t(abyte0, ai1);
F(ai1, ai);
x(ai1, abyte0);



278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/oracle_ebs_authentication/security.rb', line 278

def d(abyte0, ai)
  ai1 = [nil]*2
  t(abyte0, ai1)
  # puts "<br/>DEBUG d: after t abyte0=#{abyte0.unpack("H*")[0]}"
  # puts "<br/>DEBUG d: after t ai1=#{ai1.join(",")}"
  f_(ai1, ai)
  # puts "<br/>DEBUG d: after F ai1=#{ai1.join(",")}"
  # puts "<br/>DEBUG d: after F ai=#{ai.join(",")}"
  x(ai1, abyte0)
  # puts "<br/>DEBUG d: after x ai1=#{ai1.join(",")}"
  # puts "<br/>DEBUG d: after x abyte0=#{abyte0.unpack("H*")[0]}"
end

#d_(abyte0, abyte1, abyte2, i1) ⇒ Object

private static void D(byte abyte0[], byte abyte1[], byte abyte2[], int i1) {



1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
# File 'lib/oracle_ebs_authentication/security.rb', line 1740

def d_(abyte0, abyte1, abyte2, i1)
#   for (int j1 = 0; j1 < 8; j1++) {
#     abyte2[j1 + i1] = (byte) (abyte0[j1] ^ abyte1[j1]);
# 
#   }
  for j1 in 0...8
    abyte2[j1 + i1] = (abyte0[j1] ^ abyte1[j1])
  end
# }
end

#decrypt(s1, s2, flag) ⇒ Object



1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
# File 'lib/oracle_ebs_authentication/security.rb', line 1654

def decrypt(s1, s2, flag)
#   String cid;
#   if (s2 != null && s2.length() > 0) {
  if (s2 != nil && s2.length() > 0)
#     if (s2.substring(0, 2).equals("ZG")) {
#       cid = newCheck(s1, s2, flag);
#     }
    if (s2[0, 2] == "ZG")
      # EBEI: Upcase case-insensitive passwords
      cid = new_check(s1.mb_chars.upcase.to_s, s2, flag)
    # EBEI: Support case sensitive passwords in R12
    elsif s2[0, 2] == "ZH"
      cid = new_check(s1, s2.gsub(/^ZH/, 'ZG'), flag)
#     else {
#       cid= oldCheck(s1, s2, flag);
#     }
    else
      cid = old_check(s1, s2, flag)
    end
#   }
#   else {
#     return false;
#   }
  else
    return false
  end
#   if (cid==null) {
#     return false;
#   } else  {
#     return true;
#   }
  return cid
# }
end

#e(ai) ⇒ Object

private static byte[] e(int ai[]) {

byte abyte0[] = new byte[4];
byte abyte1[] = null;
if (ai != null) {
  abyte1 = new byte[ai.length];
  for (int i1 = 0; i1 < ai.length; i1++) {
    abyte0[3] = (byte) (ai[i1] & 0xff);
    abyte0[2] = (byte) ( (ai[i1] & 0xff00) >> 8);
    abyte0[1] = (byte) ( (ai[i1] & 0xff0000) >> 16);
    abyte0[0] = (byte) ( (ai[i1] & 0xff000000) >> 24);
    abyte1[i1] = (byte) (abyte0[0] ^ abyte0[1] ^ abyte0[2] ^ abyte0[3]);
  }

}
return abyte1;

}



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/oracle_ebs_authentication/security.rb', line 307

def e(ai)
  abyte0 = "\0"*4
  abyte1 = nil
  if (ai != nil)
    abyte1 = "\0"*(ai.length)
    for i1 in 0...ai.length
      abyte0[3] = (ai[i1] & 0xff)
      abyte0[2] = ( (ai[i1] & 0xff00) >> 8)
      abyte0[1] = ( (ai[i1] & 0xff0000) >> 16)
      abyte0[0] = ( (ai[i1] & 0xff000000) >> 24)
      abyte1[i1] = (abyte0[0] ^ abyte0[1] ^ abyte0[2] ^ abyte0[3])
    end
  end
  return abyte1
end

#e_(s1) ⇒ Object

private static void E(String s1) { }



1753
1754
# File 'lib/oracle_ebs_authentication/security.rb', line 1753

def e_(s1)
end

#f(i1) ⇒ Object

private static byte f(int i1) {

byte byte0 = 0;
int j1 = (char) i1 & 0x40;
if (j1 >= 1) {
  byte0 = (byte) ( (char) i1 - 55);
}
else {
  byte0 = (byte) ( (char) i1 & 0xf);
}
return byte0;

}



334
335
336
337
338
339
340
341
342
343
# File 'lib/oracle_ebs_authentication/security.rb', line 334

def f(i1)
  byte0 = 0
  j1 = i1 & 0x40
  if (j1 >= 1)
    byte0 = i1 - 55
  else
    byte0 = i1 & 0xf
  end
  return byte0
end

#f_(ai, ai1) ⇒ Object

private static void F(int ai[], int ai1[]) {



1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
# File 'lib/oracle_ebs_authentication/security.rb', line 1757

def f_(ai, ai1)
#   int j2 = 0;
  j2 = 0
#   int l1 = ai[0];
  l1 = ai[0]
#   int k1 = ai[1];
  k1 = ai[1]
#   int j1 = (l1 >>> 4 ^ k1) & 0xf0f0f0f;
# TODO: check that it is safe to replace >>> with >>
  j1 = (l1 >> 4 ^ k1) & 0xf0f0f0f
#   k1 ^= j1;
  k1 ^= j1
#   l1 ^= j1 << 4;
  l1 ^= (j1 << 4) & 0xffffffff
#   j1 = (l1 >>> 16 ^ k1) & 0xffff;
# TODO: check that it is safe to replace >>> with >>
  j1 = (l1 >> 16 ^ k1) & 0xffff
#   k1 ^= j1;
  k1 ^= j1
#   l1 ^= j1 << 16;
  l1 ^= (j1 << 16) & 0xffffffff
#   j1 = (k1 >>> 2 ^ l1) & 0x33333333;
# TODO: check that it is safe to replace >>> with >>
  j1 = (k1 >> 2 ^ l1) & 0x33333333
#   l1 ^= j1;
  l1 ^= j1
#   k1 ^= j1 << 2;
  k1 ^= (j1 << 2) & 0xffffffff
#   j1 = (k1 >>> 8 ^ l1) & 0xff00ff;
  j1 = (k1 >> 8 ^ l1) & 0xff00ff
#   l1 ^= j1;
  l1 ^= j1
#   k1 ^= j1 << 8;
  k1 ^= (j1 << 8) & 0xffffffff
#   k1 = (k1 << 1 | k1 >>> 31 & 1) & -1;
# TODO: check that it is safe to replace >>> with >>
  k1 = (k1 << 1 | k1 >> 31 & 1) & 0xffffffff
#   j1 = (l1 ^ k1) & 0xaaaaaaaa;
  j1 = (l1 ^ k1) & 0xaaaaaaaa
#   l1 ^= j1;
  l1 ^= j1
#   k1 ^= j1;
  k1 ^= j1
#   l1 = (l1 << 1 | l1 >>> 31 & 1) & -1;
# TODO: check that it is safe to replace >>> with >>
  l1 = (l1 << 1 | l1 >> 31 & 1) & 0xffffffff
#   for (int i2 = 0; i2 < 8; i2++) {
  for i2 in 0...8
#     j1 = k1 << 28 | k1 >>> 4;
# TODO: check that it is safe to replace >>> with >>
    j1 = (k1 << 28 | k1 >> 4) & 0xffffffff
#     long l2 = 0L;
# TODO: check if long integeres are processed automatically
    l2 = 0
#     l2 = ai1[j2];
    l2 = ai1[j2]
#     j1 ^= ai1[j2];
    j1 ^= ai1[j2]
#     j2++;
    j2 += 1
#     int i1 = bj[j1 & 0x3f];
    i1 = Bj[j1 & 0x3f]
#     i1 |= L[j1 >>> 8 & 0x3f];
# TODO: check if long integeres are processed automatically
    i1 |= L[j1 >> 8 & 0x3f]
#     i1 |= P[j1 >>> 16 & 0x3f];
    i1 |= P[j1 >> 16 & 0x3f]
#     i1 |= T[j1 >>> 24 & 0x3f];
    i1 |= T[j1 >> 24 & 0x3f]
#     j1 = k1 ^ ai1[j2];
    j1 = k1 ^ ai1[j2]
#     j2++;
    j2 += 1
#     i1 |= bg[j1 & 0x3f];
    i1 |= Bg[j1 & 0x3f]
#     i1 |= bm[j1 >>> 8 & 0x3f];
    i1 |= Bm[j1 >> 8 & 0x3f]
#     i1 |= N[j1 >>> 16 & 0x3f];
    i1 |= N[j1 >> 16 & 0x3f]
#     i1 |= R[j1 >>> 24 & 0x3f];
    i1 |= R[j1 >> 24 & 0x3f]
#     l1 ^= i1;
    l1 ^= i1
#     j1 = l1 << 28 | l1 >>> 4;
    j1 = (l1 << 28 | l1 >> 4) & 0xffffffff
#     j1 ^= ai1[j2];
    j1 ^= ai1[j2]
#     j2++;
    j2 += 1
#     i1 = bj[j1 & 0x3f];
    i1 = Bj[j1 & 0x3f]
#     i1 |= L[j1 >>> 8 & 0x3f];
    i1 |= L[j1 >> 8 & 0x3f]
#     i1 |= P[j1 >>> 16 & 0x3f];
    i1 |= P[j1 >> 16 & 0x3f]
#     i1 |= T[j1 >>> 24 & 0x3f];
    i1 |= T[j1 >> 24 & 0x3f]
#     j1 = l1 ^ ai1[j2];
    j1 = l1 ^ ai1[j2]
#     j2++;
    j2 += 1
#     i1 |= bg[j1 & 0x3f];
    i1 |= Bg[j1 & 0x3f]
#     i1 |= bm[j1 >>> 8 & 0x3f];
    i1 |= Bm[j1 >> 8 & 0x3f]
#     i1 |= N[j1 >>> 16 & 0x3f];
    i1 |= N[j1 >> 16 & 0x3f]
#     i1 |= R[j1 >>> 24 & 0x3f];
    i1 |= R[j1 >> 24 & 0x3f]
#     k1 ^= i1;
    k1 ^= i1
#   }
  end
# 
#   k1 = k1 << 31 | k1 >>> 1;
  k1 = (k1 << 31 | k1 >> 1) & 0xffffffff
#   j1 = (l1 ^ k1) & 0xaaaaaaaa;
  j1 = (l1 ^ k1) & 0xaaaaaaaa
#   l1 ^= j1;
  l1 ^= j1
#   k1 ^= j1;
  k1 ^= j1
#   l1 = l1 << 31 | l1 >>> 1;
  l1 = l1 << 31 | l1 >> 1
#   j1 = (l1 >>> 8 ^ k1) & 0xff00ff;
  j1 = (l1 >> 8 ^ k1) & 0xff00ff
#   k1 ^= j1;
  k1 ^= j1
#   l1 ^= j1 << 8;
  l1 ^= (j1 << 8) & 0xffffffff
#   j1 = (l1 >>> 2 ^ k1) & 0x33333333;
  j1 = (l1 >> 2 ^ k1) & 0x33333333
#   k1 ^= j1;
  k1 ^= j1
#   l1 ^= j1 << 2;
  l1 ^= (j1 << 2) & 0xffffffff
#   j1 = (k1 >>> 16 ^ l1) & 0xffff;
  j1 = (k1 >> 16 ^ l1) & 0xffff
#   l1 ^= j1;
  l1 ^= j1
#   k1 ^= j1 << 16;
  k1 ^= (j1 << 16) & 0xffffffff
#   j1 = (k1 >>> 4 ^ l1) & 0xf0f0f0f;
  j1 = (k1 >> 4 ^ l1) & 0xf0f0f0f
#   l1 ^= j1;
  l1 ^= j1
#   k1 ^= j1 << 4;
  k1 ^= (j1 << 4) & 0xffffffff
#   ai[0] = k1;
  ai[0] = k1
#   ai[1] = l1;
  ai[1] = l1
# }
end

#g(abyte0, abyte1) ⇒ Object

private static byte[] g(byte abyte0[], byte abyte1[]) {



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/oracle_ebs_authentication/security.rb', line 346

def g(abyte0, abyte1)
#   if (abyte0.length < 32) {
#     return null;
#   }
  if (abyte0.length < 32)
    # puts "<br/>DEBUG g: nil1"
    return nil
  end
#   if (abyte1.length % 8 != 0) {
#     return null;
#   }
  if (abyte1.length % 8 != 0)
    # puts "<br/>DEBUG g: nil2"
    return nil
  end
#   int i1 = abyte1.length / 8;
  i1 = abyte1.length / 8
#   byte abyte3[] = new byte[8];
  abyte3 = "\0"*8
#   byte abyte4[] = new byte[8];
  abyte4 = "\0"*8
#   byte abyte5[] = new byte[8];
  abyte5 = "\0"*8
#   byte abyte2[] = new byte[8];
  abyte2 = "\0"*8
#   System.arraycopy(abyte0, 0, abyte3, 0, 8);
  abyte3[0,8] = abyte0[0, 8]
#   System.arraycopy(abyte0, 8, abyte4, 0, 8);
  abyte4[0,8] = abyte0[8, 8]
#   System.arraycopy(abyte0, 16, abyte5, 0, 8);
  abyte5[0,8] = abyte0[16, 8]
#   System.arraycopy(abyte0, 24, abyte2, 0, 8);
  abyte2[0,8] = abyte0[24, 8]
#   int ai[] = l(abyte3, false);
  ai = l(abyte3, false)
#   int ai1[] = l(abyte4, true);
  ai1 = l(abyte4, true)
#   int ai2[] = l(abyte5, false);
  ai2 = l(abyte5, false)
#   byte abyte6[] = new byte[abyte1.length];
  abyte6 = "\0"*(abyte1.length)
#   int j1 = 0;
  j1 = 0
#   for (int k1 = 0; j1 < i1; k1 += 8) {
  k1 = 0
  while (j1 < i1)
#     q(abyte1, k1, abyte6, k1, ai, ai1, ai2, abyte2, false);
    q(abyte1, k1, abyte6, k1, ai, ai1, ai2, abyte2, false)
    # puts "<br/>DEBUG g: after q() abyte6=#{abyte6.unpack("H*")[0]}"
#     j1++;
    j1 += 1
#   }
    k1 += 8
  end
# 
#   byte byte0 = abyte6[abyte1.length - 1];
  byte0 = abyte6[abyte1.length - 1]
  # puts "<br/>DEBUG g: abyte1=#{abyte1.unpack("H*")[0]}"
  # puts "<br/>DEBUG g: abyte1.length=#{abyte1.length}"
  # puts "<br/>DEBUG g: abyte6=#{abyte6.unpack("H*")[0]}"
#   if (byte0 < 1 || byte0 > 8) {
#     return null;
#   }
  if (byte0 < 1 || byte0 > 8)
    # puts "<br/>DEBUG g: nil3"
    # puts "<br/>DEBUG g: byte0=#{byte0}"
    return nil
  end
#   for (int l1 = abyte1.length - byte0; l1 < abyte1.length; l1++) {
  for l1 in (abyte1.length-byte0)...abyte1.length
#     if (abyte6[l1] != byte0) {
#       return null;
#     }
    if (abyte6[l1] != byte0)
      # puts "<br/>DEBUG g: nil4"
      return nil
    end
#   }
  end
# 
#   byte abyte7[] = new byte[abyte1.length - byte0];
  abyte7 = "\0"*(abyte1.length - byte0)
#   System.arraycopy(abyte6, 0, abyte7, 0, abyte1.length - byte0);
  abyte7[0, abyte1.length - byte0] = abyte6[0, abyte1.length - byte0]
#   return abyte7;
  # puts "<br/>DEBUG g: abyte7=#{abyte7.unpack("H*")[0]}"
  return abyte7
# }
end

#g_(abyte0, abyte1) ⇒ Object

private static byte[] G(byte abyte0[], byte abyte1[]) {



1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
# File 'lib/oracle_ebs_authentication/security.rb', line 1913

def g_(abyte0, abyte1)
#   if (abyte0.length < 32) {
#     return null;
#   }
  if (abyte0.length < 32)
    return nil
  end
#   byte abyte3[] = new byte[8];
  abyte3 = "\0"*8
#   byte abyte4[] = new byte[8];
  abyte4 = "\0"*8
#   byte abyte5[] = new byte[8];
  abyte5 = "\0"*8      
#   byte abyte2[] = new byte[8];
  abyte2 = "\0"*8
#   System.arraycopy(abyte0, 0, abyte3, 0, 8);
  abyte3[0, 8] = abyte0[0, 8]
#   System.arraycopy(abyte0, 8, abyte4, 0, 8);
  abyte4[0, 8] = abyte0[8, 8]
#   System.arraycopy(abyte0, 16, abyte5, 0, 8);
  abyte5[0, 8] = abyte0[16, 8]
#   System.arraycopy(abyte0, 24, abyte2, 0, 8);
  abyte2[0, 8] = abyte0[24, 0]
#   int ai[] = l(abyte3, true);
  ai = l(abyte3, true)
#   int ai1[] = l(abyte4, false);
  ai1 = l(abyte4, false)
#   int ai2[] = l(abyte5, true);
  ai2 = l(abyte5, true)
#   int i1 = abyte1.length % 8;
  i1 = abyte1.length % 8
#   byte byte0 = (byte) (8 - i1);
  byte0 = (8 - i1)
#   byte abyte6[] = new byte[abyte1.length + byte0];
  abyte6 = "\0"*(abyte1.length + byte0)
#   int j1 = abyte6.length / 8 - 1;
  j1 = abyte6.length / 8 - 1
#   int k1 = 8 * j1;
  k1 = 8 * j1
#   byte abyte7[] = new byte[8];
  abyte7 = "\0"*8
#   System.arraycopy(abyte1, k1, abyte7, 0, i1);
  abyte7[0, i1] = abyte1[k1, i1]
#   for (int l1 = i1; l1 < 8; l1++) {
#     abyte7[l1] = byte0;
# 
#   }
  for l1 in i1...8
    abyte7[l1] = byte0
  end
#   int i2 = 0;
  i2 = 0
#   for (int j2 = 0; i2 < j1; j2 += 8) {
#     q(abyte1, j2, abyte6, j2, ai, ai1, ai2, abyte2, true);
#     i2++;
#   }
  j2 = 0
  while (i2 < j1)
    q(abyte1, j2, abyte6, j2, ai, ai1, ai2, abyte2, true)
    i2 += 1
    j2 += 8
  end
# 
#   q(abyte7, 0, abyte6, k1, ai, ai1, ai2, abyte2, true);
  q(abyte7, 0, abyte6, k1, ai, ai1, ai2, abyte2, true)
#   return abyte6;
  return abyte6
# }
end

#h(ai) ⇒ Object

private static void h(int ai[])

ai[4] = j(ai[0], 5) + o(ai[1], ai[2], ai[3]) + ai[4] + ai[5] + 0xca62c1d6;
ai[2] = j(ai[1], 30);



440
441
442
443
# File 'lib/oracle_ebs_authentication/security.rb', line 440

def h(ai)
  ai[4] = j(ai[0], 5) + o(ai[1], ai[2], ai[3]) + ai[4] + ai[5] + 0xca62c1d6
  ai[2] = j(ai[1], 30)
end

#h_(ai) ⇒ Object

private static void H(int ai[])

ai[4] = j(ai[0], 5) + r(ai[1], ai[2], ai[3]) + ai[4] + ai[5] + 0x5a827999;
ai[2] = j(ai[1], 30);



1987
1988
1989
1990
# File 'lib/oracle_ebs_authentication/security.rb', line 1987

def h_(ai)
  ai[4] = j(ai[0], 5) + r(ai[1], ai[2], ai[3]) + ai[4] + ai[5] + 0x5a827999
  ai[2] = j(ai[1], 30)
end

#hash(s1) ⇒ Object

static String hash(String s1) {



902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/oracle_ebs_authentication/security.rb', line 902

def hash(s1)
#   if (s1 == null) {
#     return null;
#   }
  if (s1 == nil)
    return nil
  end
#   byte abyte0[];
#   try {
#     abyte0 = s1.getBytes("UTF8");
#   }
#   catch (UnsupportedEncodingException _ex) {
#     return null;
#   }
  abyte0 = s1.dup
#   byte abyte1[] = y(null, abyte0);
  abyte1 = y(nil, abyte0)
#   return z(abyte1);
  return z(abyte1)
# }
end

#i(abyte0, abyte1, abyte2) ⇒ Object

private static byte[] i(byte abyte0[], byte abyte1[], byte abyte2[])

return G(y(abyte0, abyte1), abyte2);



448
449
450
# File 'lib/oracle_ebs_authentication/security.rb', line 448

def i(abyte0, abyte1, abyte2)
  return g_(y(abyte0, abyte1), abyte2)
end

#i_(ai) ⇒ Object

private static void I(int ai[])

ai[4] = j(ai[0], 5) + n(ai[1], ai[2], ai[3]) + ai[4] + ai[5] + 0x6ed9eba1;
ai[2] = j(ai[1], 30);



1996
1997
1998
1999
# File 'lib/oracle_ebs_authentication/security.rb', line 1996

def i_(ai)
  ai[4] = j(ai[0], 5) + n(ai[1], ai[2], ai[3]) + ai[4] + ai[5] + 0x6ed9eba1
  ai[2] = j(ai[1], 30)
end

#j(i1, j1) ⇒ Object

private static int j(int i1, int j1)

return i1 << j1 | i1 >>> 32 - j1;

TODO: check impact of >>> substitution with >>



456
457
458
# File 'lib/oracle_ebs_authentication/security.rb', line 456

def j(i1, j1)
  return (i1 << j1 | i1 >> 32 - j1) & 0xffffffff
end

#k(abyte0, abyte1, i1) ⇒ Object

private static byte[] k(byte abyte0[], byte abyte1[], int i1) {



461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
# File 'lib/oracle_ebs_authentication/security.rb', line 461

def k(abyte0, abyte1, i1)
#   if (abyte0 == null || abyte1 == null) {
#     return null;
#   }
  if (abyte0 == nil || abyte1 == nil)
    return nil
#   else {
#     int ai[] = a(abyte0, abyte0.length);
#     byte abyte2[] = e(ai);
#     byte abyte3[] = new byte[258];
#     B(abyte3, abyte2, null, 5);
#     byte abyte4[] = new byte[i1];
#     B(abyte3, abyte1, abyte4, i1);
#     return abyte4;
#   }
  else
    ai = a(abyte0, abyte0.length)
    abyte2 = e(ai)
    abyte3 = "\0"*258
    b_(abyte3, abyte2, nil, 5)
    abyte4 = "\0"*i1
    b_(abyte3, abyte1, abyte4, i1)
    return abyte4
  end
# }
end

#l(abyte0, flag) ⇒ Object

private static int[] l(byte abyte0[], boolean flag) {



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'lib/oracle_ebs_authentication/security.rb', line 489

def l(abyte0, flag)
#   byte abyte1[] = new byte[56];
  abyte1 = "\0"*56
#   byte abyte2[] = new byte[56];
  abyte2 = "\0"*56
#   int ai[] = new int[32];
  ai = [nil]*32
#   for (int j1 = 0; j1 < 56; j1++) {
#     byte byte0 = V[j1];
#     int l2 = byte0 & 7;
#     abyte1[j1] = (byte) ( (abyte0[byte0 >>> 3] & bi[l2]) == 0 ? 0 : 1);
#   }
# TODO: check impact of >>> substitution with >>
  for j1 in 0...56
    byte0 = V[j1]
    l2 = byte0 & 7
    abyte1[j1] = ( (abyte0[byte0 >> 3] & Bi[l2]) == 0 ? 0 : 1)
  end
# 
#   for (int i1 = 0; i1 < 16; i1++) {
  for i1 in 0...16
#     int i3;
#     if (flag) {
#       i3 = i1 << 1;
#     }
    if (flag)
      i3 = i1 << 1
#     else {
#       i3 = 15 - i1 << 1;
#     }
    else
      i3 = 15 - i1 << 1
    end
#     int j3 = i3 + 1;
    j3 = i3 + 1
#     ai[i3] = ai[j3] = 0;
    ai[i3] = ai[j3] = 0
#     for (int k1 = 0; k1 < 28; k1++) {
    for k1 in 0...28
#       int j2 = k1 + bb[i1];
      j2 = k1 + Bb[i1]
#       if (j2 < 28) {
#         abyte2[k1] = abyte1[j2];
#       }
      if (j2 < 28)
        abyte2[k1] = abyte1[j2]
#       else {
#         abyte2[k1] = abyte1[j2 - 28];
#       }
      else
        abyte2[k1] = abyte1[j2 - 28]
      end
#     }
    end
# 
#     for (int l1 = 28; l1 < 56; l1++) {
    for l1 in 28...56
#       int k2 = l1 + bb[i1];
      k2 = l1 + Bb[i1]
#       if (k2 < 56) {
#         abyte2[l1] = abyte1[k2];
#       }
      if (k2 < 56)
        abyte2[l1] = abyte1[k2]
#       else {
#         abyte2[l1] = abyte1[k2 - 28];
#       }
      else
        abyte2[l1] = abyte1[k2 - 28]
      end
#     }
    end
# 
#     for (int i2 = 0; i2 < 24; i2++) {
    for i2 in 0...24
#       if (abyte2[S[i2]] != 0) {
#         ai[i3] |= W[i2];
#       }
      if (abyte2[S[i2]] != 0)
        ai[i3] |= W[i2]
      end
#       if (abyte2[S[i2 + 24]] != 0) {
#         ai[j3] |= W[i2];
#       }
      if (abyte2[S[i2 + 24]] != 0)
        ai[j3] |= W[i2]
      end
#     }
    end
# 
#   }
  end
# 
#   return C(ai);
  return c_(ai)
# }
end

#m(abyte0) ⇒ Object

private static char[] m(byte abyte0[]) {



640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
# File 'lib/oracle_ebs_authentication/security.rb', line 640

def m(abyte0)
#   char ac1[];
#   label0: {
  while true
#     if (abyte0 == null) {
#       return null;
#     }
    if (abyte0 == nil)
      return nil
    end
#     char ac[] = new char[abyte0.length];
    ac = "\0"*(abyte0.length)
#     int i1 = 0;
    i1 = 0
#     boolean flag = false;
    flag = false
#     boolean flag1 = false;
    flag1 = false
#     ac1 = null;
    ac1 = nil
#     try {
    begin
#       for (int j1 = 0; j1 < abyte0.length; j1++) {
      break_value = for j1 in 0...abyte0.length do
#         byte byte0 = abyte0[j1];
        byte0 = abyte0[j1]
#         if ( (byte0 & 0x80) == 0) {
#           ac[i1++] = (char) byte0;
#           if ( (char) byte0 == 0) {
#             break;
#           }
#           continue;
#         }
        if ( (byte0 & 0x80) == 0)
          ac[i1] = byte0
          i1 += 1
          if ( byte0 == 0)
            break
          end
          next
        end
#         if ( (byte0 & 0xe0) == 192) {
#           char c1 = (char) ( (byte0 & 0x1f) << 6 & 0x7c0);
#           byte0 = abyte0[++j1];
#           if ( (byte0 & 0x80) == 128) {
#             c1 |= byte0 & 0x3f;
#             ac[i1++] = c1;
#             continue;
#           }
#           break label0;
#         }
        if ( (byte0 & 0xe0) == 192)
          c1 = ( (byte0 & 0x1f) << 6 & 0x7c0)
          j1 += 1
          byte0 = abyte0[j1]
          if ( (byte0 & 0x80) == 128)
            c1 |= byte0 & 0x3f
            ac[i1] = c1
            i1 += 1
            next
          end
          break :label0
        end
#         if ( (byte0 & 0xf0) != 224) {
#           continue;
#         }
        if ( (byte0 & 0xf0) != 224)
          continue
        end
#         char c2 = (char) ( (byte0 & 0xf) << 12 & 0xf000);
        c2 = ( (byte0 & 0xf) << 12 & 0xf000)
#         byte0 = abyte0[++j1];
        j1 += 1
        byte0 = abyte0[j1]
#         if ( (byte0 & 0x80) != 128) {
#           break label0;
#         }
        if ( (byte0 & 0x80) != 128)
          break :label0
        end
#         c2 |= (byte0 & 0x3f) << 6 & 0xfc0;
        c2 |= (byte0 & 0x3f) << 6 & 0xfc0
#         byte0 = abyte0[++j1];
        j1 += 1
        byte0 = abyte0[j1]
#         if ( (byte0 & 0x80) != 128) {
#           break label0;
#         }
        if ( (byte0 & 0x80) != 128)
          break :label0
        end
#         c2 |= byte0 & 0x3f;
        c2 |= byte0 & 0x3f
#         ac[i1++] = c2;
        ac[i1] = c2
        i1 += 1
#       }
      end
      # RSI: jump back to label0 if brake was called with :label0
      if break_value == :label0
        next
      end
# 
#       ac1 = new char[i1];
      ac1 = "\0"*i1
#       System.arraycopy(ac, 0, ac1, 0, i1);
      ac1[0,i1] = ac[0,i1]
#     }
#     catch (ArrayIndexOutOfBoundsException _ex) {
#       ac1 = null;
#     }
    end
# TODO: when this exception could happen?
#   }
#   return ac1;
# }
# RSI: if we are here then we should return value and escape endless loop
    return ac1
  end
end

#n(i1, j1, k1) ⇒ Object

private static int n(int i1, int j1, int k1)

return i1 ^ j1 ^ k1;



765
766
767
# File 'lib/oracle_ebs_authentication/security.rb', line 765

def n(i1, j1, k1)
  return i1 ^ j1 ^ k1
end

#new_check(s1, s2, flag) ⇒ Object

static String newCheck(String s1, String s2, boolean flag) {



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/oracle_ebs_authentication/security.rb', line 130

def new_check(s1, s2, flag)
#   if (s1 == null || s2 == null ||
#       s2.length() >= "ZG_ENCRYPT_FAILED_".length() &&
#       s2.substring(0,
#                    "ZG_ENCRYPT_FAILED_".length()).equals("ZG_ENCRYPT_FAILED_")) {
#     return null;
#   }
  if (s1 == nil || s2 == nil ||
      s2.length >= "ZG_ENCRYPT_FAILED_".length &&
      s2[0, "ZG_ENCRYPT_FAILED_".length] == "ZG_ENCRYPT_FAILED_")
    return nil
  end
#   byte abyte0[];
#   try {
#     abyte0 = s1.getBytes("UTF8");
#   }
#   catch (UnsupportedEncodingException _ex) {
#     return null;
#   }
  abyte0 = s1.dup
#   int l2 = abyte0.length;
  l2 = abyte0.length
#   int i3 = s2.length();
  i3 = s2.length
#   int i1 = 1;
  i1 = 1
#   byte byte0 = 2;
  byte0 = 2
#   int j1 = i3 - 2 - i1 * 2;
  j1 = i3 - 2 - i1 * 2
#   if (j1 <= 0) {
#     return null;
#   }
  if (j1 <= 0)
    return nil
  end
#   int k1 = (j1 / 16) * 8;
  k1 = (j1 / 16) * 8
#   if (k1 <= 0) {
#     return null;
#   }
  if (k1 <= 0)
    return nil
  end
#   int l1 = (j1 % 16) / 2;
  l1 = (j1 % 16) / 2
#   int i2 = l1 + i1;
  i2 = l1 + i1
#   int j2 = k1 - 1 - byte0;
  j2 = k1 - 1 - byte0
#   if (j2 <= 0) {
#     return null;
#   }
  if (j2 <= 0)
    return nil
  end
#   if (!s2.substring(0, 2).equals("ZG")) {
#     return null;
#   }
  if (not s2[0, 2] == "ZG")
    return nil
  end
#   String s3 = s2.substring(2);
  s3 = s2[2..-1]
#   byte abyte1[] = p(s3);
  abyte1 = p(s3)
#   byte abyte2[] = new byte[abyte1.length - i2];
  abyte2 = "\0"*(abyte1.length - i2)
#   byte abyte3[] = new byte[i2];
  abyte3 = "\0"*i2
#   System.arraycopy(abyte1, 0, abyte2, 0, abyte1.length - i2);
  abyte2[0, abyte1.length - i2] = abyte1[0, abyte1.length - i2]
#   System.arraycopy(abyte1, abyte1.length - i2, abyte3, 0, i2);
  abyte3[0, i2] = abyte1[abyte1.length - i2, i2]
#   byte abyte4[] = new byte[i2 + l2];
  abyte4 = "\0"*(i2 + l2)
#   System.arraycopy(abyte3, 0, abyte4, 0, i2);
  abyte4[0, i2] = abyte3[0, i2]
#   System.arraycopy(abyte0, 0, abyte4, i2, l2);
  abyte4[i2, l2] = abyte0[0, l2]
#   byte abyte5[] = v(null, abyte4, abyte2);
  # puts "<br/>DEBUG new_check: abyte4=#{abyte4.inspect} abyte2=#{abyte2.unpack("H*")[0]}"
  abyte5 = v(nil, abyte4, abyte2)
#   if (abyte5 == null) {
#     return null;
#   }
  if (abyte5 == nil)
    # puts "<br/>DEBUG new_check: :nil6"
    return nil
  end
#   int j3 = abyte5.length;
  j3 = abyte5.length
#   for (int k2 = byte0; k2 < abyte5.length; k2++) {
#     if (abyte5[k2] != 0) {
#       continue;
#     }
#     j3 = k2;
#     break;
#   }
  for k2 in byte0...abyte5.length
    if (abyte5[k2] != 0)
      next
    end
    j3 = k2
    break
  end
# 
#   byte abyte6[] = new byte[j3 - byte0];
  abyte6 = "\0"*(j3 - byte0)
#   System.arraycopy(abyte5, byte0, abyte6, 0, j3 - byte0);
  abyte6[0, j3 - byte0] = abyte5[byte0, j3 - byte0]
#   String s4;
#   try {
#     s4 = new String(abyte6, "UTF8");
#   }
#   catch (UnsupportedEncodingException _ex) {
#     return null;
#   }
  s4 = abyte6
#   if (s4 != null && flag) {
#     return w(s4, 0, flag);
#   }
  if (s4 != nil && flag)
    return w(s4, 0, flag)
#   else {
#     return s4;
#   }
  else
    return s4
  end
# }
end

#new_control(s1, s2, i1, j1) ⇒ Object

static String newControl(String s1, String s2, int i1, int j1) {



925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
# File 'lib/oracle_ebs_authentication/security.rb', line 925

def new_control(s1, s2, i1, j1)
#   if (s1 == null || s2 == null) {
#     return "ZG_ENCRYPT_FAILED_BADINPUT";
#   }
  if (s1 == nil || s2 == nil)
    return "ZG_ENCRYPT_FAILED_BADINPUT"
  end
#   int k1;
#   if (i1 > 0) {
#     k1 = i1;
#   }
  if (i1 > 0)
    k1 = i1
#   else
#   if (j1 == 32) {
#     k1 = 100;
#   }
  elsif (j1 == 32)
    k1 = 100
#   else
#   if (j1 < 32 && j1 == s2.length()) {
#     k1 = 100;
#   }
  elsif (j1 < 32 && j1 == s2.length())
    k1 = 100
#   else {
#     byte abyte1[];
#     try {
#       abyte1 = s2.getBytes("UTF8");
#     }
#     catch (UnsupportedEncodingException _ex) {
#       return "ZG_ENCRYPT_FAILED_MISC";
#     }
#     k1 = ( (abyte1.length + 10) / 8) * 16 + 4 + 14;
#   }
  else
    abyte1 = s2.dup
    k1 = ( (abyte1.length + 10) / 8) * 16 + 4 + 14
  end
#   int l1 = 1;
  l1 = 1
#   byte byte0 = 2;
  byte0 = 2
#   int i2 = k1 - 2 - l1 * 2;
  i2 = k1 - 2 - l1 * 2
#   if (i2 <= 0) {
#     return "ZG_ENCRYPT_FAILED_SMALLBUF";
#   }
  if (i2 <= 0)
    return "ZG_ENCRYPT_FAILED_SMALLBUF"
  end
#   int j2 = (i2 / 16) * 8;
  j2 = (i2 / 16) * 8
#   if (j2 <= 0) {
#     return "ZG_ENCRYPT_FAILED_SMALLBUF";
#   }
  if (j2 <= 0)
    return "ZG_ENCRYPT_FAILED_SMALLBUF"
  end
#   int k2 = (i2 % 16) / 2;
  k2 = (i2 % 16) / 2
#   int l2 = k2 + l1;
  l2 = k2 + l1
#   int i3 = j2 - 1 - byte0;
  i3 = j2 - 1 - byte0
#   if (i3 <= 0) {
#     return "ZG_ENCRYPT_FAILED_SMALLBUF";
#   }
  if (i3 <= 0)
    return "ZG_ENCRYPT_FAILED_SMALLBUF"
  end
#   byte abyte0[];
#   byte abyte2[];
#   try {
#     abyte0 = s1.getBytes("UTF8");
#     abyte2 = s2.getBytes("UTF8");
#   }
#   catch (UnsupportedEncodingException _ex) {
#     return "ZG_ENCRYPT_FAILED_MISC";
#   }
  abyte0 = s1.dup
  abyte2 = s2.dup
#   int j3 = abyte0.length;
  j3 = abyte0.length
#   int k3 = abyte2.length;
  k3 = abyte2.length
#   if (k3 > i3) {
#     return "ZG_ENCRYPT_FAILED_CHARSET_CLIP";
#   }
  if (k3 > i3)
    return "ZG_ENCRYPT_FAILED_CHARSET_CLIP"
  end
#   Random random = new Random();
#   int ai[] = new int[l2];
  ai = [nil]*l2
#   for (int l3 = 0; l3 < l2; l3++) {
#     ai[l3] = random.nextInt();
# 
#   }
  for l3 in 0...l2
    ai[l3] = rand(2**32)-2**31
  end
#   byte abyte3[] = e(ai);
  abyte3 = e(ai)
#   ai = null;
  ai = nil
#   byte byte1 = byte0;
  byte1 = byte0
#   ai = new int[byte1];
  ai = [nil]*byte1
#   for (int i4 = 0; i4 < byte1; i4++) {
#     ai[i4] = random.nextInt();
# 
#   }
  for i4 in 0...byte1
    ai[i4] = rand(2**32)-2**31
  end
#   byte abyte4[] = e(ai);
  abyte4 = e(ai)
#   ai = null;
  ai = nil
#   int j4 = i3 - k3;
  j4 = i3 - k3
#   ai = new int[j4];
  ai = [nil]*j4
#   for (int k4 = 0; k4 < j4; k4++) {
  for k4 in 0...j4
#     if (k4 == 0) {
#       ai[k4] = 0;
#     }
    if (k4 == 0)
      ai[k4] = 0
#     else {
#       ai[k4] = random.nextInt();
# 
#     }
    else
      ai[k4] = rand(2**32)-2**31
    end
#   }
  end
#   byte abyte5[] = e(ai);
  abyte5 = e(ai)
#   ai = null;
  ai = nil
#   byte abyte6[] = new byte[byte1 + j4 + k3];
  abyte6 = "\0"*(byte1 + j4 + k3)
#   System.arraycopy(abyte4, 0, abyte6, 0, byte1);
  abyte6[0, byte1] = abyte4[0, byte1]
#   System.arraycopy(abyte2, 0, abyte6, byte1, k3);
  abyte6[byte1, k3] = abyte2[0, k3]
#   System.arraycopy(abyte5, 0, abyte6, byte1 + k3, j4);
  abyte6[byte1+k3, j4] = abyte5[0, j4]
#   byte abyte7[] = new byte[l2 + j3];
  abyte7 = "\0"*(l2 + j3)
#   System.arraycopy(abyte3, 0, abyte7, 0, l2);
  abyte7[0, l2] = abyte3[0, l2]
#   System.arraycopy(abyte0, 0, abyte7, l2, j3);
  abyte7[l2, j3] = abyte0[0, j3]
#   byte abyte8[] = i(null, abyte7, abyte6);
  abyte8 = i(nil, abyte7, abyte6)
#   if (abyte8 == null) {
#     return "ZG_ENCRYPT_FAILED_MISC";
#   }
  if (abyte8 == nil)
    return "ZG_ENCRYPT_FAILED_MISC"
#   else {
#     byte abyte9[] = new byte[abyte8.length + l2];
#     System.arraycopy(abyte8, 0, abyte9, 0, abyte8.length);
#     System.arraycopy(abyte3, 0, abyte9, abyte8.length, l2);
#     String s3 = z(abyte9);
#     return "ZG" + s3;
#   }
  else
    abyte9 = "\0"*(abyte8.length + l2)
    abyte9[0, abyte8.length] = abyte8[0, abyte8.length]
    abyte9[abyte8.length, l2] = abyte3[0, l2]
    s3 = z(abyte9)
    return "ZG" + s3
  end
# }
end

#o(i1, j1, k1) ⇒ Object

private static int o(int i1, int j1, int k1)

return i1 ^ j1 ^ k1;



772
773
774
# File 'lib/oracle_ebs_authentication/security.rb', line 772

def o(i1, j1, k1)
  return i1 ^ j1 ^ k1
end

#old_check(s1, s2, flag) ⇒ Object

static String oldCheck(String s1, String s2, boolean flag) {



1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
# File 'lib/oracle_ebs_authentication/security.rb', line 1375

def old_check(s1, s2, flag)
#   byte abyte0[] = A(s1.toCharArray());
  abyte0 = a_(s1.dup)
#   byte abyte1[] = p(s2);
  abyte1 = p(s2)
#   byte abyte2[] = k(abyte0, abyte1, abyte1.length);
  abyte2 = k(abyte0, abyte1, abyte1.length)
#   char ac[] = m(abyte2);
  ac = m(abyte2)
#   if (ac != null) {
#     String s3 = new String(ac);
#     return w(s3, 0, flag);
#   }
  if (ac != nil)
    s3 = ac.to_s
#   else {
#     return null;
#   }
  else
    return nil
  end
# }
end

#old_control(s1, s2, i1) ⇒ Object

static String oldControl(String s1, String s2, int i1) {



588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
# File 'lib/oracle_ebs_authentication/security.rb', line 588

def old_control(s1, s2, i1)
#   if (s1 == null || s2 == null) {
#     return null;
#   }
  if (s1 == nil || s2 == nil)
    return nil
  end
#   byte abyte0[] = A(s1.toCharArray());
  abyte0 = a_(s1.dup)
#   int j1 = s2.length();
  #j1 = s2.mb_chars.length
  j1 = s2.length
  
#   if (j1 > i1 - 1) {
#     j1 = i1 - 1;
#   }
  if (j1 > i1 - 1)
    j1 = i1 - 1
  end
#   Random random = new Random();
# RSI: no need to create object here
#   int k1 = i1 - j1 - 1;
  k1 = i1 - j1 - 1
#   int ai[] = new int[k1];
  ai = [nil]*k1
#   for (int l1 = 0; l1 < k1; l1++) {
#     ai[l1] = random.nextInt();
# 
#   }
# TODO: substitute Java random.nextInt() with ruby
  for l1 in 0..k1
    # simulation of random.nextInt()
    ai[l1] = rand(2**32)-2**31
  end
#   byte abyte1[] = e(ai);
  abyte1 = e(ai)
#   byte abyte2[] = A( (new String(s2 + '\0')).toCharArray());
  abyte2 = a_( (s2 + "\0") )
#   byte abyte3[] = new byte[k1 + abyte2.length];
  abyte3 = "\0"*(k1 + abyte2.length)
#   System.arraycopy(abyte2, 0, abyte3, 0, abyte2.length);
  abyte3[0, abyte2.length] = abyte2[0, abyte2.length]
#   System.arraycopy(abyte1, 0, abyte3, abyte2.length, k1);
  abyte3[abyte2.length, k1] = abyte1[0, k1]
#   byte abyte4[] = k(abyte0, abyte3, i1);
  abyte4 = k(abyte0, abyte3, i1)
#   return z(abyte4);
  return z(abyte4)
# }
end

#p(s1) ⇒ Object

private static byte[] p(String s1) {



784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
# File 'lib/oracle_ebs_authentication/security.rb', line 784

def p(s1)
#   boolean flag = false;
  flag = false
#   boolean flag1 = false;
  flag1 = false
#   int i1 = 0;
  i1 = 0
#   int j1 = 0;
  j1 = 0
#   byte abyte0[] = null;
  abyte0 = nil
#   if (s1 == null) {
#     return null;
#   }
  if (s1 == nil)
    return nil
  end
#   int k1 = s1.length() / 2;
  k1 = s1.length / 2
#   if (k1 > 0) {
  if (k1 > 0)
#     abyte0 = new byte[k1];
    abyte0 = "\0"*k1
#     for (; k1 > 0; k1--) {
    while (k1 > 0)
#       char c1 = s1.charAt(i1++);
      #c1 = s1.chars[i1]
      c1 = s1[i1]
      i1 += 1
#       char c2 = s1.charAt(i1++);
      #c2 = s1.chars[i1]
      c2 = s1[i1]
      i1 += 1
#       abyte0[j1++] = (byte) (f(c1) << 4 | f(c2));
      abyte0[j1] = (f(c1) << 4 | f(c2)) & 0xffffffff
      j1 += 1
#     }
      k1 -= 1
    end
# 
#   }
  end
#   return abyte0;
  return abyte0
# }
end

#q(abyte0, i1, abyte1, j1, ai, ai1, ai2, abyte2, flag) ⇒ Object

private static void q(byte abyte0[], int i1, byte abyte1[], int j1, int ai[],

int ai1[], int ai2[], byte abyte2[],
boolean flag) {


834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
# File 'lib/oracle_ebs_authentication/security.rb', line 834

def q(abyte0, i1, abyte1, j1, ai,
      ai1, ai2, abyte2,
      flag)
#   byte abyte3[] = new byte[8];
  abyte3 = "\0"*8
#   System.arraycopy(abyte0, i1, abyte3, 0, 8);
  abyte3[0, 8] = abyte0[i1, 8]
#   if (!flag) {
#     d(abyte3, ai2);
#     d(abyte3, ai1);
#     d(abyte3, ai);
#     D(abyte3, abyte2, abyte1, j1);
#     System.arraycopy(abyte0, i1, abyte2, 0, 8);
#     return;
#   }
  if (!flag)
    # puts "<br/>DEBUG q: initial abyte3=#{abyte3.unpack("H*")[0]}"
    # puts "<br/>DEBUG q: initial ai2=#{ai2.join(',')}"
    # puts "<br/>DEBUG q: initial ai1=#{ai1.join(',')}"
    # puts "<br/>DEBUG q: initial ai=#{ai.join(',')}"
    d(abyte3, ai2)
    # puts "<br/>DEBUG q: abyte3=#{abyte3.unpack("H*")[0]}"
    d(abyte3, ai1)
    # puts "<br/>DEBUG q: abyte3=#{abyte3.unpack("H*")[0]}"
    d(abyte3, ai)
    # puts "<br/>DEBUG q: abyte3=#{abyte3.unpack("H*")[0]}"
    d_(abyte3, abyte2, abyte1, j1)
    # puts "<br/>DEBUG q: abyte3=#{abyte3.unpack("H*")[0]}"
    # puts "<br/>DEBUG q: abyte2=#{abyte2.unpack("H*")[0]}"
    # puts "<br/>DEBUG q: abyte1=#{abyte1.unpack("H*")[0]}"
    abyte2[0, 8] = abyte0[i1, 8]
    return
#   else {
#     D(abyte3, abyte2, abyte3, 0);
#     d(abyte3, ai);
#     d(abyte3, ai1);
#     d(abyte3, ai2);
#     System.arraycopy(abyte3, 0, abyte2, 0, 8);
#     System.arraycopy(abyte3, 0, abyte1, j1, 8);
#     return;
#   }
  else
    d_(abyte3, abyte2, abyte3, 0);
    d(abyte3, ai);
    d(abyte3, ai1);
    d(abyte3, ai2);
    abyte2[0, 8] = abyte3[0, 8]
    abyte1[j1, 8] = abyte3[0, 8]
    return
  end
# }
end

#r(i1, j1, k1) ⇒ Object

private static int r(int i1, int j1, int k1)

return i1 & j1 | ~i1 & k1;



890
891
892
# File 'lib/oracle_ebs_authentication/security.rb', line 890

def r(i1, j1, k1)
  return i1 & j1 | ~i1 & k1
end

#s(i1, j1, k1) ⇒ Object

private static int s(int i1, int j1, int k1)

return i1 & j1 | i1 & k1 | j1 & k1;



897
898
899
# File 'lib/oracle_ebs_authentication/security.rb', line 897

def s(i1, j1, k1)
  return i1 & j1 | i1 & k1 | j1 & k1
end

#t(abyte0, ai) ⇒ Object

private static void t(byte abyte0[], int ai[]) {



1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
# File 'lib/oracle_ebs_authentication/security.rb', line 1109

def t(abyte0, ai)
#   int i1 = 0;
  i1 = 0
#   ai[0] = (abyte0[i1] & 0xff) << 24;
  ai[0] = ((abyte0[i1] & 0xff) << 24)  & 0xffffffff
#   i1++;
  i1 += 1
#   ai[0] |= (abyte0[i1] & 0xff) << 16;
  ai[0] |= ((abyte0[i1] & 0xff) << 16) & 0xffffffff
#   i1++;
  i1 += 1
#   ai[0] |= (abyte0[i1] & 0xff) << 8;
  ai[0] |= ((abyte0[i1] & 0xff) << 8) & 0xffffffff
#   i1++;
  i1 += 1
#   ai[0] |= abyte0[i1] & 0xff;
  ai[0] |= abyte0[i1] & 0xff
#   i1++;
  i1 += 1
#   ai[1] = (abyte0[i1] & 0xff) << 24;
  ai[1] = ((abyte0[i1] & 0xff) << 24) & 0xffffffff
#   i1++;
  i1 += 1
#   ai[1] |= (abyte0[i1] & 0xff) << 16;
  ai[1] |= ((abyte0[i1] & 0xff) << 16) & 0xffffffff
#   i1++;
  i1 += 1
#   ai[1] |= (abyte0[i1] & 0xff) << 8;
  ai[1] |= ((abyte0[i1] & 0xff) << 8) & 0xffffffff
#   i1++;
  i1 += 1
#   ai[1] |= abyte0[i1] & 0xff;
  ai[1] |= abyte0[i1] & 0xff
# }
end

#u(ai, ai1) ⇒ Object

private static int u(int ai[], int ai1[]) {



1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
# File 'lib/oracle_ebs_authentication/security.rb', line 1146

def u(ai, ai1)
#   boolean flag = false;
  flag = false
#   boolean flag1 = false;
  flag1 = false
#   int ai2[] = new int[80];
  ai2 = [nil]*80
#   int l1 = 0;
  l1 = 0
#   int ai3[] = new int[5];
  ai3 = [nil]*5
#   int ai4[] = new int[6];
  ai4 = [nil]*6
#   int ai5[] = new int[5];
  ai5 = [nil]*5
#   ai3[0] = 0x67452301;
#   ai3[1] = 0xefcdab89;
#   ai3[2] = 0x98badcfe;
#   ai3[3] = 0x10325476;
#   ai3[4] = 0xc3d2e1f0;
  ai3[0] = 0x67452301
  ai3[1] = 0xefcdab89
  ai3[2] = 0x98badcfe
  ai3[3] = 0x10325476
  ai3[4] = 0xc3d2e1f0
#   if (ai1 != null) {
  if (ai1 != nil)
#     if (ai != null) {
#       System.arraycopy(ai, 0, ai4, 0, 5);
#     }
    if (ai != nil)
      ai4[0, 5] = ai[0, 5]
    end
#     byte byte0 = 80;
    byte0 = 80
#     int i1;
#     for (i1 = 0; i1 < 16; i1++) {
#       ai2[i1] = ai1[i1];
# 
#     }
    for i1 in 0...16
      ai2[i1] = ai1[i1]
    end
#     for (; i1 < byte0; i1++) {
#       ai2[i1] = ai2[i1 - 3] ^ ai2[i1 - 8] ^ ai2[i1 - 14] ^ ai2[i1 - 16];
# 
#     }
    while (i1 < byte0)
      ai2[i1] = ai2[i1 - 3] ^ ai2[i1 - 8] ^ ai2[i1 - 14] ^ ai2[i1 - 16]
      i1 += 1
    end
#     for (int j1 = 0; j1 < 80; j1++) {
    for j1 in 0...80
#       if (j1 != 0) {
#         System.arraycopy(ai4, 0, ai5, 0, 5);
#         ai4[0] = ai5[4];
#         ai4[1] = ai5[0];
#         ai4[2] = ai5[1];
#         ai4[3] = ai5[2];
#         ai4[4] = ai5[3];
#       }
      if (j1 != 0)
        ai5[0, 5] = ai4[0, 5]
        ai4[0] = ai5[4];
        ai4[1] = ai5[0];
        ai4[2] = ai5[1];
        ai4[3] = ai5[2];
        ai4[4] = ai5[3];
      end
#       ai4[5] = ai2[j1];
      ai4[5] = ai2[j1]
#       if (j1 < 20) {
#         H(ai4);
#       }
      if (j1 < 20)
        h_(ai4)
#       else
#       if (j1 < 40) {
#         I(ai4);
#       }
      elsif (j1 < 40)
        i_(ai4)
#       else
#       if (j1 < 60) {
#         c(ai4);
#       }
      elsif (j1 < 60)
        c(ai4)
#       else
#       if (j1 < 80) {
#         h(ai4);
#       }
      elsif (j1 < 80)
        h(ai4)
      end
#     }
    end
# 
#     ai3[0] = ai4[4];
#     ai3[1] = ai4[0];
#     ai3[2] = ai4[1];
#     ai3[3] = ai4[2];
#     ai3[4] = ai4[3];
    ai3[0] = ai4[4];
    ai3[1] = ai4[0];
    ai3[2] = ai4[1];
    ai3[3] = ai4[2];
    ai3[4] = ai4[3];
#     for (int k1 = 0; k1 < byte0; k1++) {
#       ai2[k1] = 0;
# 
#     }
    for k1 in 0...byte0
      ai2[k1] = 0
    end
#   }
  end
#   if (ai != null) {
#     ai[0] = ai3[0];
#     ai[1] = ai3[1];
#     ai[2] = ai3[2];
#     ai[3] = ai3[3];
#     ai[4] = ai3[4];
#   }
  if (ai != nil)
    ai[0] = ai3[0];
    ai[1] = ai3[1];
    ai[2] = ai3[2];
    ai[3] = ai3[3];
    ai[4] = ai3[4];
  end
#   l1 = ai3[0] ^ ai3[1] ^ ai3[2] ^ ai3[3] ^ ai3[4];
  l1 = ai3[0] ^ ai3[1] ^ ai3[2] ^ ai3[3] ^ ai3[4]
#   return l1;
  return l1
# }
end

#v(abyte0, abyte1, abyte2) ⇒ Object

private static byte[] v(byte abyte0[], byte abyte1[], byte abyte2[])

return g(y(abyte0, abyte1), abyte2);



1287
1288
1289
# File 'lib/oracle_ebs_authentication/security.rb', line 1287

def v(abyte0, abyte1, abyte2)
  return g(y(abyte0, abyte1), abyte2)
end

#w(s1, i1, flag) ⇒ Object

private static String w(String s1, int i1, boolean flag) {



1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
# File 'lib/oracle_ebs_authentication/security.rb', line 1292

def w(s1, i1, flag)
#   if (s1 == null) {
#     return "";
#   }
  if (s1 == nil)
    return ""
  end
#   int j1 = s1.length();
# TODO: should String be converted to Ruby Unicode chars string? 
  j1 = s1.length
#   int k1 = s1.indexOf('\0');
  k1 = s1.index("\0")
#   if (k1 > -1) {
#     j1 = k1;
#   }
  if (k1 > -1)
    j1 = k1
  end
#   int l1;
#   if (j1 > i1 && i1 > 0) {
#     l1 = i1;
#   }
  if (j1 > i1 && i1 > 0)
    l1 = i1
#   else {
#     l1 = j1;
#   }
  else
    l1 = j1
  end
#   if (flag) {
#     return new String(s1.substring(0, l1).toUpperCase(Locale.US));
#   }
  if (flag)
    # TODO: should we do Unicode upcase?
    return s1[0, l1].upcase
#   else {
#     return new String(s1.substring(0, l1));
#   }
  else
    return s1[0, l1]
  end
# }
end

#x(ai, abyte0) ⇒ Object

private static void x(int ai[], byte abyte0[]) {



1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
# File 'lib/oracle_ebs_authentication/security.rb', line 1338

def x(ai, abyte0)
#   int i1 = 0;
  i1 = 0
#   abyte0[i1] = (byte) (ai[0] >> 24 & 0xff);
  abyte0[i1] = (ai[0] >> 24 & 0xff)
#   i1++;
  i1 += 1
#   abyte0[i1] = (byte) (ai[0] >> 16 & 0xff);
  abyte0[i1] = (ai[0] >> 16 & 0xff)
#   i1++;
  i1 += 1
#   abyte0[i1] = (byte) (ai[0] >> 8 & 0xff);
  abyte0[i1] = (ai[0] >> 8 & 0xff)
#   i1++;
  i1 += 1
#   abyte0[i1] = (byte) (ai[0] & 0xff);
  abyte0[i1] = (ai[0] & 0xff)
#   i1++;
  i1 += 1
#   abyte0[i1] = (byte) (ai[1] >> 24 & 0xff);
  abyte0[i1] = (ai[1] >> 24 & 0xff)
#   i1++;
  i1 += 1
#   abyte0[i1] = (byte) (ai[1] >> 16 & 0xff);
  abyte0[i1] = (ai[1] >> 16 & 0xff)
#   i1++;
  i1 += 1
#   abyte0[i1] = (byte) (ai[1] >> 8 & 0xff);
  abyte0[i1] = (ai[1] >> 8 & 0xff)
#   i1++;
  i1 += 1
#   abyte0[i1] = (byte) (ai[1] & 0xff);
  abyte0[i1] = (ai[1] & 0xff)
# }
end

#y(abyte0, abyte1) ⇒ Object

private static byte[] y(byte abyte0[], byte abyte1[]) {



1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
# File 'lib/oracle_ebs_authentication/security.rb', line 1400

def y(abyte0, abyte1)
  # puts "<br/>DEBUG y: abyte0=#{abyte0.nil? ? "nil" : abyte0.unpack("H*")[0]}"
  # puts "<br/>DEBUG y: abyte1=#{abyte1.nil? ? "nil" : abyte1.unpack("H*")[0]}"
#   byte abyte2[] = new byte[32];
  abyte2 = "\0"*32
#   MessageDigest messagedigest;
#   try {
#     messagedigest = MessageDigest.getInstance("SHA");
#   }
#   catch (NoSuchAlgorithmException _ex) {
#     return null;
#   }
  messagedigest = Digest::SHA1.new
#   messagedigest.reset();
  messagedigest.reset
#   byte byte0 = 20;
  byte0 = 20
#   if (abyte0 != null && abyte0.length > 0) {
#     messagedigest.update(abyte0);
#   }
  if (abyte0 != nil && abyte0.length > 0)
    messagedigest.update(abyte0)
  end
#   if (abyte1 != null && abyte1.length > 0) {
#     messagedigest.update(abyte1);
#   }
  if (abyte1 != nil && abyte1.length > 0)
    messagedigest.update(abyte1)
  end
#   messagedigest.update( (byte) 1);
  messagedigest.update(1.chr)
#   byte abyte3[] = messagedigest.digest();
  abyte3 = messagedigest.digest
  # puts "<br/>DEBUG y: abyte3=#{abyte3.nil? ? "nil" : abyte3.unpack("H*")[0]}"
#   System.arraycopy(abyte3, 0, abyte2, 0, byte0);
  abyte2[0, byte0] = abyte3[0, byte0]
#   messagedigest.reset();
  messagedigest.reset()
#   if (abyte0 != null && abyte0.length > 0) {
#     messagedigest.update(abyte0);
#   }
  if (abyte0 != nil && abyte0.length > 0)
    messagedigest.update(abyte0)
  end
#   if (abyte1 != null && abyte1.length > 0) {
#     messagedigest.update(abyte1);
#   }
  if (abyte1 != nil && abyte1.length > 0)
    messagedigest.update(abyte1)
  end
#   messagedigest.update( (byte) 2);
  messagedigest.update( 2.chr )
#   abyte3 = messagedigest.digest();
  abyte3 = messagedigest.digest
#   System.arraycopy(abyte3, 0, abyte2, byte0, 32 - byte0);
  abyte2[byte0, 32 - byte0] = abyte3[0, 32 - byte0]
#   return abyte2;
  # puts "<br/>DEBUG y: abyte2=#{abyte2.unpack("H*")[0]}"
  return abyte2
# }
end

#z(abyte0) ⇒ Object

private static String z(byte abyte0[]) {



1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
# File 'lib/oracle_ebs_authentication/security.rb', line 1463

def z(abyte0)
# #   if (abyte0 == null) {
# #     return null;
# #   }
#   if (abyte0 == nil)
#     return nil
#   end
# #   String s1 = "0123456789ABCDEF";
#   s1 = "0123456789ABCDEF"
# #   StringBuffer stringbuffer = new StringBuffer(abyte0.length * 2);
#   stringbuffer = ""
# #   int i1 = 0;
#   i1 = 0
# #   for (int j1 = abyte0.length; j1 > 0; ) {
#   j1 = abyte0.length
#   while (j1 > 0)
# #     byte byte0 = abyte0[i1];
#     byte0 = abyte0[i1]
# #     stringbuffer.append(s1.charAt(byte0 >> 4 & 0xf));
#     stringbuffer << s1[byte0 >> 4 & 0xf]
# #     stringbuffer.append(s1.charAt(byte0 & 0xf));
#     stringbuffer << s1[byte0 & 0xf]
# #     j1--;
#     j1 -= 1
# #     i1++;
#     i1 += 1
# #   }
#   end
# # 
# #   return stringbuffer.toString();
#   return stringbuffer
# # }
  abyte0.unpack("H*")[0].upcase
end