diff options
author | Tibor Král <tibor.kral@pantheon.tech> | 2019-01-18 16:54:28 +0100 |
---|---|---|
committer | Tibor Král <tibor.kral@pantheon.tech> | 2019-01-18 16:20:32 +0000 |
commit | 7645a98e4c92a20d45a8a1417db498db1b075080 (patch) | |
tree | 2cb8d5925cbe912b73712370d8b7b6a39ce54d54 /ipsec/ipsec-impl/src/main/java/io | |
parent | d10368dffa17254096c99f64d7e1d77644f50a6d (diff) |
Update IPSec writers
- Fix data_len fields in api messages
- Add enum for authentication types
Change-Id: I266bb096488b41d4e97b6fa4c5a557b71925be77
Signed-off-by: Tibor Král <tibor.kral@pantheon.tech>
Diffstat (limited to 'ipsec/ipsec-impl/src/main/java/io')
4 files changed, 42 insertions, 2 deletions
diff --git a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/dto/AuthMethod.java b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/dto/AuthMethod.java new file mode 100644 index 000000000..9131d14e0 --- /dev/null +++ b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/dto/AuthMethod.java @@ -0,0 +1,32 @@ +/* + * 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; + } +} diff --git a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyCustomizer.java b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyCustomizer.java index 300ea6b8e..6cb37329c 100644 --- a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyCustomizer.java +++ b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyCustomizer.java @@ -20,6 +20,7 @@ import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; 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; @@ -137,7 +138,9 @@ public class Ikev2PolicyCustomizer extends FutureJVppCustomizer 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); } @@ -145,11 +148,12 @@ public class Ikev2PolicyCustomizer extends FutureJVppCustomizer 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); } diff --git a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyIdentityCustomizer.java b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyIdentityCustomizer.java index 4c11f1633..f6b100c54 100644 --- a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyIdentityCustomizer.java +++ b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyIdentityCustomizer.java @@ -93,6 +93,7 @@ public class Ikev2PolicyIdentityCustomizer extends FutureJVppCustomizer request.idType = 5; request.data = ipv6AddressNoZoneToArray(((Ipv6Address) identityData).getIpv6Address()); } + request.dataLen = request.data.length; } @Override diff --git a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizer.java b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizer.java index d7bbee32d..c29137d26 100644 --- a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizer.java +++ b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizer.java @@ -153,6 +153,7 @@ public class IpsecSadEntryCustomizer extends FutureJVppCustomizer return; } targetEntry.integrityKey = integKey.getBytes(); + targetEntry.integrityKeyLength = (byte) integKey.getBytes().length; } } @@ -174,6 +175,7 @@ public class IpsecSadEntryCustomizer extends FutureJVppCustomizer return; } targetEntry.integrityKey = integKey.getBytes(); + targetEntry.integrityKeyLength = (byte) integKey.getBytes().length; } } @@ -199,6 +201,7 @@ public class IpsecSadEntryCustomizer extends FutureJVppCustomizer return; } targetEntry.cryptoKey = cryptoKey.getBytes(); + targetEntry.cryptoKeyLength = (byte) cryptoKey.getBytes().length; } } |