This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git
commit d8cd67aaac54c6d26404a6ca8cd96cac5b866cc4 Author: Gary Gregory <[email protected]> AuthorDate: Mon Dec 12 22:01:38 2022 -0500 Add missing test --- .../crypto/cipher/OpenSslGaloisCounterMode.java | 6 ++--- .../crypto/cipher/OpenSslCommonModeTest.java | 31 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java index b637525..b07000b 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java +++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java @@ -270,16 +270,14 @@ final class OpenSslGaloisCounterMode extends AbstractOpenSslFeedbackCipher { // must be called after initialized. if (aadBuffer == null) { // update has already been called - throw new IllegalStateException - ("Update has been called; no more AAD data"); + throw new IllegalStateException("Update has been called; no more AAD data"); } aadBuffer.write(aad, 0, aad.length); } private void processAAD() { if (aadBuffer != null && aadBuffer.size() > 0) { - OpenSslNative.updateByteArray(context, aadBuffer.toByteArray(), - 0, aadBuffer.size(), null, 0, 0); + OpenSslNative.updateByteArray(context, aadBuffer.toByteArray(), 0, aadBuffer.size(), null, 0, 0); aadBuffer = null; } } diff --git a/src/test/java/org/apache/commons/crypto/cipher/OpenSslCommonModeTest.java b/src/test/java/org/apache/commons/crypto/cipher/OpenSslCommonModeTest.java new file mode 100644 index 0000000..585ce5e --- /dev/null +++ b/src/test/java/org/apache/commons/crypto/cipher/OpenSslCommonModeTest.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.commons.crypto.cipher; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; + +public class OpenSslCommonModeTest { + + @Test + public void testUpdateAAD() { + assertThrows(UnsupportedOperationException.class, () -> new OpenSslCommonMode(0, 0, 0).updateAAD(null)); + } +}
