Skip to content

Commit

Permalink
Merge pull request #1 from lucee/LDEV-5051
Browse files Browse the repository at this point in the history
LDEV-4816 tmp fix, use lucee 6.0 argon jar
  • Loading branch information
zspitzer authored Jul 29, 2024
2 parents c601fd5 + 7ae3062 commit ade0db2
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 19 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/main-version-picker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ jobs:
luceeVersionQuery: ${{ inputs.lucee_version_query }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ inputs.java_version }}
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java_version }}
distribution: 'adopt'
- name: Cache Maven packages
uses: actions/cache@v4
with:
Expand All @@ -51,18 +46,28 @@ jobs:
path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache
key: lucee-downloads
enableCrossOsArchive: true
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'
- name: Build with Ant
run: ant -noinput -verbose -buildfile build.xml
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: image-lex
name: argon2-lex
path: dist/*.lex
- name: Checkout Lucee
uses: actions/checkout@v4
with:
repository: lucee/lucee
path: lucee
- name: Set up JDK ${{ inputs.java_version }}
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java_version }}
distribution: 'adopt'
- name: Run Lucee Test Suite (testFilter="argon2")
uses: lucee/script-runner@main
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: image-lex
name: argon2-lex
path: dist/*.lex
- name: Checkout Lucee
uses: actions/checkout@v4
Expand Down
Binary file removed source/java/libs/org.lucee.argon2-2.11.0.jar
Binary file not shown.
Binary file added source/java/libs/org.lucee.argon2-2.7.0.jar
Binary file not shown.
Binary file not shown.
4 changes: 1 addition & 3 deletions source/java/src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Manifest-Version: 1.0
Export-Package: org.lucee.extension.argon2
Bundle-ManifestVersion: 2
Require-Bundle: org.lucee.argon2;bundle-version=2.11.0,
org.lucee.argon2-jvm-nolibs;bundle-version=2.11.0,
com.sun.jna;bundle-version=5.8.0
Require-Bundle: org.lucee.argon2;bundle-version=2.7.0
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static boolean call(PageContext pc, String input, String hash) throws Pag
Argon2Types type;
String variant = getVariant(pc, hash);
if (Util.isEmpty(variant, true))
throw eng.getExceptionUtil().createFunctionException(pc, "GenerateArgon2Hash", 1, "variant", "The Variant should be ARGON2i or ARGON2d", null);
throw eng.getExceptionUtil().createFunctionException(pc, "GenerateArgon2Hash", 1, "variant", "The Variant should be ARGON2i, ARGON2id or ARGON2d", null);
variant = variant.trim();
switch (variant.toLowerCase()) {
case "argon2i":
Expand All @@ -38,8 +38,13 @@ public static boolean call(PageContext pc, String input, String hash) throws Pag
case "argon2d":
type = Argon2Types.ARGON2d;
break;
case "argon2id":
type = Argon2Types.ARGON2id;
break;

default:
throw eng.getExceptionUtil().createFunctionException(pc, "Argon2CheckHash", 1, "variant", "The Variant should be ARGON2i or ARGON2d", null);
throw eng.getExceptionUtil().createFunctionException(pc, "Argon2CheckHash", 1, "variant",
"The Variant should be ARGON2i, ARGON2id or ARGON2d, was [" + variant + "]", null);
}
Argon2 argon2 = Argon2Factory.create(type);
char[] carrInput = input == null ? new char[0] : input.toCharArray();
Expand Down
15 changes: 11 additions & 4 deletions source/java/src/org/lucee/extension/argon2/GenerateArgon2Hash.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ public Object invoke(PageContext pc, Object[] args) throws PageException {
case "argon2d":
variant = Argon2Types.ARGON2d;
break;
case "argon2id":
variant = Argon2Types.ARGON2id;
break;
default:
throw eng.getExceptionUtil().createFunctionException(pc, "GenerateArgon2Hash", 1, "variant", "The Variant should be ARGON2i or ARGON2d", null);
throw eng.getExceptionUtil().createFunctionException(pc, "GenerateArgon2Hash", 1, "variant",
"The Variant should be ARGON2i, ARGON2id or ARGON2d, was [" + tmp + "]" , null);
}
}
else variant = null;
Expand All @@ -54,7 +58,8 @@ public Object invoke(PageContext pc, Object[] args) throws PageException {
if (args.length > 2) {
parallelismFactor = cast.toIntValue(args[2]);
if (parallelismFactor < 1 || parallelismFactor > 10) {
throw eng.getExceptionUtil().createFunctionException(pc, "GenerateArgon2Hash", 2, "parallelismFactor", "The parallelism factor value should be between 1 and 10",
throw eng.getExceptionUtil().createFunctionException(pc, "GenerateArgon2Hash", 2, "parallelismFactor",
"The parallelism factor value should be between 1 and 10, was [" + parallelismFactor + "]",
null);
}
}
Expand All @@ -64,7 +69,8 @@ public Object invoke(PageContext pc, Object[] args) throws PageException {
if (args.length > 3) {
memory = cast.toIntValue(args[3]);
if (memory < 8 || memory > 100000) {
throw eng.getExceptionUtil().createFunctionException(pc, "GenerateArgon2Hash", 3, "memoryCost", "The memory cost value should be between 8 and 100000", null);
throw eng.getExceptionUtil().createFunctionException(pc, "GenerateArgon2Hash", 3, "memoryCost",
"The memory cost value should be between 8 and 100000, was [" + memory + "]", null);
}
}

Expand All @@ -73,7 +79,8 @@ public Object invoke(PageContext pc, Object[] args) throws PageException {
if (args.length > 4) {
iterations = cast.toIntValue(args[4]);
if (iterations < 1 || iterations > 20) {
throw eng.getExceptionUtil().createFunctionException(pc, "GenerateArgon2Hash", 4, "iterations", "The iterations value should be between 1 and 20", null);
throw eng.getExceptionUtil().createFunctionException(pc, "GenerateArgon2Hash", 4, "iterations",
"The iterations value should be between 1 and 20, was [" + iterations + "]", null);
}
}

Expand Down
28 changes: 25 additions & 3 deletions tests/functions/Argon2CheckHash.cfc
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
component extends="org.lucee.cfml.test.LuceeTestCase" labels="argon2" {
function run( testResults , testBox ) {
describe( title="Test suite for Argon2CheckHash()", body=function() {
it(title="check Argon2CheckHash", body = function( currentSpec ) {
it(title="check Argon2CheckHash (default)", body = function( currentSpec ) {
var hashedValue = GenerateArgon2Hash("CFDocs.org");
expect(Argon2CheckHash( "CFDocs.org", hashedValue)).ToBeTrue();
});
});

it(title="check Argon2CheckHash (argon2i)", body = function( currentSpec ) {
var hashedValue = GenerateArgon2Hash("CFDocs.org", "argon2i");
expect(Argon2CheckHash( "CFDocs.org", hashedValue)).ToBeTrue();
});

it(title="check Argon2CheckHash (argon2d)", body = function( currentSpec ) {
var hashedValue = GenerateArgon2Hash("CFDocs.org", "argon2d");
expect(Argon2CheckHash( "CFDocs.org", hashedValue)).ToBeTrue();
});

it(title="check Argon2CheckHash (argon2id)", body = function( currentSpec ) {
var hashedValue = GenerateArgon2Hash("CFDocs.org", "argon2id");
expect(Argon2CheckHash( "CFDocs.org", hashedValue)).ToBeTrue();
});

it(title="check Argon2CheckHash", body = function( currentSpec ) {
var hashedValue = GenerateArgon2Hash("lucee","ARGON2i");
var hashedValue = "$argon2i$v=19$m=8,t=1,p=1$ccCBeNYDdvv5FYAAjNYaoA$+sfZnhMn1IA1VIslUFqd6dk2+LX1But4mhC8Wx4Q+Dg";
expect(Argon2CheckHash( "lucee", hashedValue)).ToBeTrue();
});
});
}

}
}

32 changes: 32 additions & 0 deletions tests/functions/GenerateArgon2Hash.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
component extends="org.lucee.cfml.test.LuceeTestCase" labels="argon2" {

function run( testResults , testBox ) {
describe( title="Test suite for Argon2CheckHash()", body=function() {
it(title="check Argon2CheckHash (default)", body = function( currentSpec ) {
var hashedValue = GenerateArgon2Hash("CFDocs.org");
expect( hashedValue ).toInclude( "$argon2i$" );
expect(Argon2CheckHash( "CFDocs.org", hashedValue)).ToBeTrue();
});

it(title="check Argon2CheckHash (argon2i)", body = function( currentSpec ) {
var hashedValue = GenerateArgon2Hash("CFDocs.org", "argon2i");
expect( hashedValue ).toInclude( "$argon2i$" );
expect(Argon2CheckHash( "CFDocs.org", hashedValue)).ToBeTrue();
});

it(title="check Argon2CheckHash (argon2d)", body = function( currentSpec ) {
var hashedValue = GenerateArgon2Hash("CFDocs.org", "argon2d");
expect( hashedValue ).toInclude( "$argon2d$" );
expect(Argon2CheckHash( "CFDocs.org", hashedValue)).ToBeTrue();
});

it(title="check Argon2CheckHash (argon2id)", body = function( currentSpec ) {
var hashedValue = GenerateArgon2Hash("CFDocs.org", "argon2id");
expect( hashedValue ).toInclude( "$argon2id$" );
expect(Argon2CheckHash( "CFDocs.org", hashedValue)).ToBeTrue();
});
});
}

}

0 comments on commit ade0db2

Please sign in to comment.