Skip to content

Commit 6229858

Browse files
authored
Merge pull request #129 from cconlon/aesModes
Add AES-ECB/CTR/OFB/CCM/CMAC/GMAC
2 parents d027842 + 7e46c9e commit 6229858

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+10877
-120
lines changed

.github/workflows/line-length-check.yml

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,52 @@ jobs:
3838
# Check each changed file
3939
while IFS= read -r file; do
4040
if [[ -f "$file" ]]; then
41+
# Skip WolfCryptProvider.java as it contains service mappings
42+
# that legitimately exceed 80 characters
43+
if [[ "$file" == "src/main/java/com/wolfssl/provider/jce/WolfCryptProvider.java" ]]; then
44+
echo "⚠️ Skipping $file (contains security service mappings)"
45+
continue
46+
fi
47+
4148
echo "Checking: $file"
4249
43-
# Get added lines with line numbers and check their length
50+
# Get added lines with actual file line numbers and check their length
51+
new_line_num=0
4452
git diff "origin/$BASE_BRANCH"...HEAD "$file" | \
45-
grep -n -E '^\+[^+]' | \
46-
while IFS=':' read -r line_num added_line; do
47-
# Remove the leading +
48-
actual_line="${added_line:1}"
49-
char_count=${#actual_line}
53+
while IFS= read -r line; do
54+
# Track line numbers from diff headers - format: @@ -old_start,old_count +new_start,new_count @@
55+
if [[ "$line" =~ ^@@.*\+([0-9]+) ]]; then
56+
# Extract starting line number for new file (after +)
57+
# Subtract 1 because we'll increment before processing first line
58+
new_line_num=$((${BASH_REMATCH[1]} - 1))
59+
elif [[ "$line" =~ ^(\+[^+].*) ]]; then
60+
# This is an added line (not a +++ header)
61+
# Increment line number BEFORE processing (since this line exists in new file)
62+
new_line_num=$((new_line_num + 1))
63+
added_line="${line:1}" # Remove leading +
64+
char_count=${#added_line}
5065
51-
if [[ $char_count -gt 80 ]]; then
52-
echo "❌ $file:$line_num - Line too long ($char_count characters)"
53-
echo " Line: $actual_line"
54-
echo "violation" >> "$violations_file"
66+
# Skip JNI method signatures and calls to avoid false positives
67+
# These are auto-generated names that can't be shortened
68+
if [[ $char_count -gt 80 ]]; then
69+
# Check if this is a JNI method signature, call, or parameter line that should be ignored
70+
if [[ "$added_line" =~ JNIEXPORT.*JNICALL.*Java_com_wolfssl_ ]] || \
71+
[[ "$added_line" =~ Java_com_wolfssl_.*\( ]] || \
72+
[[ "$added_line" =~ ^[[:space:]]*return[[:space:]]+Java_com_wolfssl_.* ]] || \
73+
[[ "$added_line" =~ ^[[:space:]]*\(JNIEnv\*[[:space:]]+env.*\) ]] || \
74+
[[ "$added_line" =~ ^[[:space:]]*JNIEnv\*[[:space:]]+env.* ]]; then
75+
echo "⚠️ $file:$new_line_num - Skipping JNI method signature/call/parameters ($char_count characters)"
76+
echo " Line: $added_line"
77+
else
78+
echo "❌ $file:$new_line_num - Line too long ($char_count characters)"
79+
echo " Line: $added_line"
80+
echo "violation" >> "$violations_file"
81+
fi
82+
fi
83+
elif [[ "$line" =~ ^[[:space:]] ]]; then
84+
# Context line (unchanged) - increment new file line number
85+
new_line_num=$((new_line_num + 1))
86+
# Removed lines (starting with -) don't affect new file line numbers
5587
fi
5688
done
5789
fi

README_JCE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,19 @@ The JCE provider currently supports the following algorithms:
104104
Cipher Class
105105
AES/CBC/NoPadding
106106
AES/CBC/PKCS5Padding
107+
AES/CCM/NoPadding
108+
AES/CTR/NoPadding
109+
AES/ECB/NoPadding
110+
AES/ECB/PKCS5Padding
107111
AES/GCM/NoPadding
112+
AES/OFB/NoPadding
108113
DESede/CBC/NoPadding
109114
RSA
110115
RSA/ECB/PKCS1Padding
111116

112117
Mac Class
118+
AESCMAC (aliased also as: AES-CMAC)
119+
AESGMAC (aliased also as: AES-GMAC)
113120
HmacMD5
114121
HmacSHA1
115122
HmacSHA224

jni/include/com_wolfssl_wolfcrypt_AesCcm.h

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jni/include/com_wolfssl_wolfcrypt_AesCmac.h

Lines changed: 95 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jni/include/com_wolfssl_wolfcrypt_AesCtr.h

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jni/include/com_wolfssl_wolfcrypt_AesEcb.h

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)