import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
private final DeviceTransactionManager deviceTransactionManager;
private final OpenRoadmInterfaces openRoadmInterfaces;
- //FNV1 128 bit hash constants
- private static final BigInteger FNV_PRIME = new BigInteger("309485009821345068724781371");
- private static final BigInteger FNV_INIT = new BigInteger("6c62272e07bb014262b821756295c58d", 16);
- private static final BigInteger FNV_MOD = new BigInteger("2").pow(128);
+ //FNV1 64 bit hash constants
+ private static final BigInteger FNV_PRIME = new BigInteger("100000001b3", 16);
+ private static final BigInteger FNV_INIT = new BigInteger("cbf29ce484222325", 16);
+ private static final BigInteger FNV_MOD = new BigInteger("2").pow(64);
public PortMappingVersion121(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
OpenRoadmInterfaces openRoadmInterfaces) {
}
/**
- * Implements the FNV-1 128bit algorithm.
+ * Implements the FNV-1 64bit algorithm.
+ * FNV-1 128bit would be ideal for 16 bytes but we need an overhead for Base64 encoding.
+ * Otherwise, the hash cannot be stored in a UTF-8 string.
* https://www.wikiwand.com/en/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#/FNV-1_hash
* https://github.com/pmdamora/fnv-cracker-app/blob/master/src/main/java/passwordcrack/cracking/HashChecker.java
* @param stringdata the String to be hashed
- * @return the hash string
+ * @return the base64 formatted hash string
*/
private String fnv(String stringdata) {
BigInteger hash = FNV_INIT;
hash = hash.xor(BigInteger.valueOf((int) b & 0xff));
}
- return hash.toString(16);
+ return Base64.getEncoder().encodeToString(hash.toByteArray());
}
}
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
private final DataBroker dataBroker;
private final DeviceTransactionManager deviceTransactionManager;
private final OpenRoadmInterfaces openRoadmInterfaces;
- //FNV1 128 bit hash constants
- private static final BigInteger FNV_PRIME = new BigInteger("309485009821345068724781371");
- private static final BigInteger FNV_INIT = new BigInteger("6c62272e07bb014262b821756295c58d", 16);
- private static final BigInteger FNV_MOD = new BigInteger("2").pow(128);
+ //FNV1 64 bit hash constants
+ private static final BigInteger FNV_PRIME = new BigInteger("100000001b3", 16);
+ private static final BigInteger FNV_INIT = new BigInteger("cbf29ce484222325", 16);
+ private static final BigInteger FNV_MOD = new BigInteger("2").pow(64);
public PortMappingVersion221(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
OpenRoadmInterfaces openRoadmInterfaces) {
}
/**
- * Implements the FNV-1 128bit algorithm.
+ * Implements the FNV-1 64bit algorithm.
+ * FNV-1 128bit would be ideal for 16 bytes but we need an overhead for Base64 encoding.
+ * Otherwise, the hash cannot be stored in a UTF-8 string.
* https://www.wikiwand.com/en/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#/FNV-1_hash
* https://github.com/pmdamora/fnv-cracker-app/blob/master/src/main/java/passwordcrack/cracking/HashChecker.java
* @param stringdata the String to be hashed
hash = hash.xor(BigInteger.valueOf((int) b & 0xff));
}
- return hash.toString(16);
+ return Base64.getEncoder().encodeToString(hash.toByteArray());
}
}
{'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
'logical-connection-point': 'XPDR1-NETWORK1', 'port-direction': 'bidirectional',
'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network',
- 'lcp-hash-val': '3b3ab304d2a6eb3c3623e52746dbb7aa'},
+ 'lcp-hash-val': 'APdT8Jzj+EVC'},
res['mapping'])
def test_11_xpdr_portmapping_NETWORK2(self):
{'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET',
'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional',
'connection-map-lcp': 'XPDR1-CLIENT3', 'port-qual': 'xpdr-network',
- 'lcp-hash-val': '3b3ab304d2a6eb3c3623e52746dbb7a9'},
+ 'lcp-hash-val': 'APdT8Jzj+EVB'},
res['mapping'])
def test_12_xpdr_portmapping_CLIENT1(self):
'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT',
'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
- 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae5'},
+ 'lcp-hash-val': 'UHyVf5o4TF0='},
res['mapping'])
def test_13_xpdr_portmapping_CLIENT2(self):
'supporting-circuit-pack-name': '1/0/C2-PLUG-CLIENT',
'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional',
'port-qual': 'xpdr-client',
- 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae6'},
+ 'lcp-hash-val': 'UHyVf5o4TF4='},
res['mapping'])
def test_14_xpdr_portmapping_CLIENT3(self):
'supporting-circuit-pack-name': '1/0/C3-PLUG-CLIENT',
'logical-connection-point': 'XPDR1-CLIENT3',
'connection-map-lcp': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional',
- 'port-qual': 'xpdr-client', 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae7'},
+ 'port-qual': 'xpdr-client', 'lcp-hash-val': 'UHyVf5o4TF8='},
res['mapping'])
def test_15_xpdr_portmapping_CLIENT4(self):
{'supporting-port': 'C4',
'supporting-circuit-pack-name': '1/0/C4-PLUG-CLIENT',
'logical-connection-point': 'XPDR1-CLIENT4', 'port-direction': 'bidirectional',
- 'port-qual': 'xpdr-client', 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae0'},
+ 'port-qual': 'xpdr-client', 'lcp-hash-val': 'UHyVf5o4TFg='},
res['mapping'])
def test_16_xpdr_device_disconnection(self):
{'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
'logical-connection-point': 'XPDR1-NETWORK1', 'port-direction': 'bidirectional',
'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network',
- 'lcp-hash-val': '3b3ab304d2a6eb3c3623e52746dbb7aa'},
+ 'lcp-hash-val': 'APdT8Jzj+EVC'},
res['nodes'][0]['mapping'])
self.assertIn(
{'supporting-port': 'C1',
'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT',
'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
- 'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae5'},
+ 'lcp-hash-val': 'UHyVf5o4TF0='},
res['nodes'][0]['mapping'])
def test_05_service_path_create(self):
'logical-connection-point': 'XPDR1-CLIENT1',
'port-direction': 'bidirectional',
'port-qual': 'xpdr-client',
- 'lcp-hash-val': '8b3efff522736722500b5e68fb6e696e'},
+ 'lcp-hash-val': 'AIg960BwzGKe'},
res['mapping'])
def test_03_get_portmapping_NETWORK1(self):
"port-qual": "xpdr-network",
"supporting-circuit-pack-name": "CP1-CFP0",
"xponder-type": "mpdr",
- 'lcp-hash-val': '1021db8d2affe7386705c438c67ea21f'},
+ 'lcp-hash-val': 'AM7VlW5NpPm3'},
res['mapping'])
def test_04_service_path_create_OCH_OTU4(self):
"port-qual": "xpdr-network",
"supporting-circuit-pack-name": "CP1-CFP0",
"xponder-type": "mpdr",
- "lcp-hash-val": "1021db8d2affe7386705c438c67ea21f"},
+ "lcp-hash-val": "AM7VlW5NpPm3"},
res['mapping'])
def test_06_check_interface_och(self):
"supporting-circuit-pack-name": "CP1-CFP0",
"xponder-type": "mpdr",
"supporting-odu4": "XPDR1-NETWORK1-ODU4",
- "lcp-hash-val": "1021db8d2affe7386705c438c67ea21f"
+ "lcp-hash-val": "AM7VlW5NpPm3"
},
res['mapping'])
'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
'logical-connection-point': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-network',
'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT1',
- 'lcp-hash-val': '8e128ba57560403cfd4ffafae38cd941'},
+ 'lcp-hash-val': 'e54EtOovlcE='},
res['mapping'])
def test_12_xpdr_portmapping_NETWORK2(self):
'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET',
'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional',
'connection-map-lcp': 'XPDR1-CLIENT2', 'port-qual': 'xpdr-network',
- 'lcp-hash-val': '8e128ba57560403cfd4ffafae38cd942'},
+ 'lcp-hash-val': 'e54EtOovlcI='},
res['mapping'])
def test_13_xpdr_portmapping_CLIENT1(self):
'supporting-circuit-pack-name': '1/0/1-PLUG-CLIENT',
'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
- 'lcp-hash-val': '3ed8ed1336784ac7c2f66c22f2f03d8'},
+ 'lcp-hash-val': 'BIyxYXnFEFA='},
res['mapping'])
def test_14_xpdr_portmapping_CLIENT2(self):
'supporting-circuit-pack-name': '1/0/2-PLUG-CLIENT',
'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional',
'connection-map-lcp': 'XPDR1-NETWORK2', 'port-qual': 'xpdr-client',
- 'lcp-hash-val': '3ed8ed1336784ac7c2f66c22f2f03db'},
+ 'lcp-hash-val': 'BIyxYXnFEFM='},
res['mapping'])
def test_15_xpdr_device_disconnection(self):
'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
'logical-connection-point': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-network',
'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT1',
- 'lcp-hash-val': '8e128ba57560403cfd4ffafae38cd941'},
+ 'lcp-hash-val': 'e54EtOovlcE='},
res['nodes'][0]['mapping'])
self.assertIn(
{'supported-interface-capability': ['org-openroadm-port-types:if-100GE'],
'supporting-circuit-pack-name': '1/0/1-PLUG-CLIENT',
'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
- 'lcp-hash-val': '3ed8ed1336784ac7c2f66c22f2f03d8'},
+ 'lcp-hash-val': 'BIyxYXnFEFA='},
res['nodes'][0]['mapping'])
def test_05_service_path_create(self):