--- /dev/null
+/*
+ * Copyright (c) 2019 PANTHEON.tech.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.ipsec.dto;
+
+public enum AuthMethod {
+ RSA_SIG((byte) 1),
+ SHARED_KEY_MIC((byte) 2);
+
+ private final byte value;
+
+ AuthMethod(final byte method) {
+ this.value = method;
+ }
+
+ public byte getValue() {
+ return value;
+ }
+}
import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.ipsec.dto.AuthMethod;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
Ikev2ProfileSetAuth request = new Ikev2ProfileSetAuth();
request.name = name.getBytes();
request.data = fileName.getBytes();
- request.authMethod = BYTE_TRUE;
+ request.dataLen = request.data.length;
+ request.isHex = BYTE_FALSE;
+ request.authMethod = AuthMethod.RSA_SIG.getValue();
getReplyForWrite(getFutureJVpp().ikev2ProfileSetAuth(request).toCompletableFuture(), id);
}
final IkeGeneralPolicyProfileGrouping.PreSharedKey preSharedKey,
final InstanceIdentifier<Policy> id) throws WriteFailedException {
final Ikev2ProfileSetAuth request = new Ikev2ProfileSetAuth();
- request.authMethod = BYTE_FALSE;
+ request.authMethod = AuthMethod.SHARED_KEY_MIC.getValue();
if (preSharedKey.getHexString() != null) {
request.isHex = BYTE_TRUE;
}
request.data = preSharedKey.stringValue().getBytes();
+ request.dataLen = request.data.length;
request.name = name.getBytes();
getReplyForWrite(getFutureJVpp().ikev2ProfileSetAuth(request).toCompletableFuture(), id);
}
request.idType = 5;
request.data = ipv6AddressNoZoneToArray(((Ipv6Address) identityData).getIpv6Address());
}
+ request.dataLen = request.data.length;
}
@Override
return;
}
targetEntry.integrityKey = integKey.getBytes();
+ targetEntry.integrityKeyLength = (byte) integKey.getBytes().length;
}
}
return;
}
targetEntry.integrityKey = integKey.getBytes();
+ targetEntry.integrityKeyLength = (byte) integKey.getBytes().length;
}
}
return;
}
targetEntry.cryptoKey = cryptoKey.getBytes();
+ targetEntry.cryptoKeyLength = (byte) cryptoKey.getBytes().length;
}
}
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
+import io.fd.hc2vpp.ipsec.dto.AuthMethod;
import io.fd.hc2vpp.ipsec.helpers.SchemaContextTestHelper;
import io.fd.honeycomb.test.tools.HoneycombTestRunner;
import io.fd.honeycomb.test.tools.annotations.InjectTestData;
if (auth != null) {
request.name = policy.getName().getBytes();
if (auth.isPresharedKey() != null && policy.getPreSharedKey() != null) {
- request.authMethod = ByteDataTranslator.BYTE_FALSE;
+ request.authMethod = AuthMethod.SHARED_KEY_MIC.getValue();
if (policy.getPreSharedKey().getHexString() != null) {
request.isHex = ByteDataTranslator.BYTE_TRUE;
}
request.data = policy.getPreSharedKey().stringValue().getBytes();
+ request.dataLen = request.data.length;
} else if (auth.isRsaSignature() != null) {
IpsecIkev2PolicyAugmentation aug = policy.augmentation(IpsecIkev2PolicyAugmentation.class);
if (aug != null && aug.getCertificate() != null) {
request.data = aug.getCertificate().getBytes();
- request.authMethod = ByteDataTranslator.BYTE_TRUE;
+ request.dataLen = request.data.length;
+ request.authMethod = AuthMethod.RSA_SIG.getValue();
}
}
}
request.idType = (byte) 1;
request.isLocal = BYTE_TRUE;
request.data = ipv4AddressNoZoneToArray(IPV4_TYPE_DATA);
+ request.dataLen = request.data.length;
verify(api).ikev2ProfileSetId(request);
}
request.idType = (byte) 2;
request.isLocal = BYTE_FALSE;
request.data = FQDN_TYPE_DATA.getBytes();
+ request.dataLen = request.data.length;
verify(api).ikev2ProfileSetId(request);
}
request.idType = (byte) 5;
request.isLocal = BYTE_FALSE;
request.data = ipv6AddressNoZoneToArray(new Ipv6Address(IPV6_TYPE_DATA));
+ request.dataLen = request.data.length;
verify(api).ikev2ProfileSetId(request);
}
request.idType = (byte) 3;
request.isLocal = BYTE_TRUE;
request.data = RFC822_TYPE_DATA.getBytes();
+ request.dataLen = request.data.length;
verify(api).ikev2ProfileSetId(request);
}
request.isTunnel = BYTE_TRUE;
request.isTunnelIpv6 = BYTE_FALSE;
request.integrityKey = INTEG_KEY.getBytes();
+ request.integrityKeyLength = (byte) request.integrityKey.length;
request.cryptoKey = CRYPTO_KEY.getBytes();
+ request.cryptoKeyLength = (byte) request.cryptoKey.length;
request.useAntiReplay = 0;
request.tunnelSrcAddress = ipv4AddressNoZoneToArray(TNL_SRC_ADDR);
request.tunnelDstAddress = ipv4AddressNoZoneToArray(TNL_DST_ADDR);
request.isTunnelIpv6 = BYTE_TRUE;
request.integrityAlgorithm = 1;
request.integrityKey = INTEG_KEY.getBytes();
+ request.integrityKeyLength = (byte) request.integrityKey.length;
request.useAntiReplay = BYTE_TRUE;
request.tunnelSrcAddress = ipv6AddressNoZoneToArray(Ipv6Address.getDefaultInstance("2001::11"));
request.tunnelDstAddress = ipv6AddressNoZoneToArray(Ipv6Address.getDefaultInstance("2001::12"));