mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-30 08:04:05 +00:00
Update packaging script to install to /opt/hirs/rimtool
This commit is contained in:
parent
64ddc39c2c
commit
3747c1911e
@ -6,10 +6,8 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile libs.minimal_json
|
compile 'com.eclipsesource.minimal-json:minimal-json:0.9.5', 'com.beust:jcommander:1.72', 'org.bouncycastle:bcmail-jdk15on:1.59'
|
||||||
compile libs.jcommander
|
testCompile 'org.testng:testng:6.8.8'
|
||||||
compile libs.bouncy_castle
|
|
||||||
testCompile libs.testng
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
@ -6,7 +6,7 @@ pushd $SCRIPT_DIR
|
|||||||
|
|
||||||
name="tcg_rim_tool"
|
name="tcg_rim_tool"
|
||||||
|
|
||||||
tar -cf $name.tar build.gradle gradle* src/ docs/
|
tar -cf $name.tar build.gradle gradle* src/ docs/ rim_fields.json keystore.jks
|
||||||
gzip $name.tar
|
gzip $name.tar
|
||||||
if [ -d rpmbuild ]; then
|
if [ -d rpmbuild ]; then
|
||||||
rm -rf rpmbuild
|
rm -rf rpmbuild
|
||||||
|
@ -15,7 +15,7 @@ public class SwidTagConstants {
|
|||||||
public static final String DEFAULT_KEYSTORE_PATH = "keystore.jks";
|
public static final String DEFAULT_KEYSTORE_PATH = "keystore.jks";
|
||||||
public static final String DEFAULT_KEYSTORE_PASSWORD = "password";
|
public static final String DEFAULT_KEYSTORE_PASSWORD = "password";
|
||||||
public static final String DEFAULT_PRIVATE_KEY_ALIAS = "selfsigned";
|
public static final String DEFAULT_PRIVATE_KEY_ALIAS = "selfsigned";
|
||||||
public static final String DEFAULT_ATTRIBUTES_FILE = "/etc/hirs/rim_fields.json";
|
public static final String DEFAULT_ATTRIBUTES_FILE = "rim_fields.json";
|
||||||
public static final String DEFAULT_ENGLISH = "en";
|
public static final String DEFAULT_ENGLISH = "en";
|
||||||
|
|
||||||
public static final String SIGNATURE_ALGORITHM_RSA_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
|
public static final String SIGNATURE_ALGORITHM_RSA_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
|
||||||
|
@ -4,6 +4,8 @@ import java.io.BufferedInputStream;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
@ -24,8 +26,8 @@ public class HashSwid {
|
|||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String get256Hash(String value) {
|
public static String get256Hash(String filepath) {
|
||||||
return getHashValue(value, SHA256);
|
return getHashValue(filepath, SHA256);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,8 +35,8 @@ public class HashSwid {
|
|||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String get384Hash(String value) {
|
public String get384Hash(String filepath) {
|
||||||
return getHashValue(value, SHA384);
|
return getHashValue(filepath, SHA384);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,24 +44,28 @@ public class HashSwid {
|
|||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String get512Hash(String value) {
|
public String get512Hash(String filepath) {
|
||||||
return getHashValue(value, SHA512);
|
return getHashValue(filepath, SHA512);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method creates the hash based on the provided algorithm and salt
|
* This method creates the hash based on the provided algorithm and salt
|
||||||
* only accessible through helper methods.
|
* only accessible through helper methods.
|
||||||
|
*
|
||||||
|
* This method assumes an input file that is small enough to read in its
|
||||||
|
* entirety. Large files should be handled similarly to the public static
|
||||||
|
* getHashValue() below.
|
||||||
*
|
*
|
||||||
* @param value string object to hash
|
* @param filepath file contents to hash
|
||||||
* @param salt random value to make the hash stronger
|
* @param salt random value to make the hash stronger
|
||||||
* @param sha the algorithm to use for the hash
|
* @param sha the algorithm to use for the hash
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static String getHashValue(String value, String sha) {
|
private static String getHashValue(String filepath, String sha) {
|
||||||
String resultString = null;
|
String resultString = null;
|
||||||
try {
|
try {
|
||||||
MessageDigest md = MessageDigest.getInstance(sha);
|
MessageDigest md = MessageDigest.getInstance(sha);
|
||||||
byte[] bytes = md.digest(value.getBytes(ENCODING));
|
byte[] bytes = md.digest(Files.readAllBytes(Paths.get(filepath)));
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
for (int i = 0; i < bytes.length; i++) {
|
for (int i = 0; i < bytes.length; i++) {
|
||||||
@ -68,6 +74,8 @@ public class HashSwid {
|
|||||||
resultString = sb.toString();
|
resultString = sb.toString();
|
||||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException grex) {
|
} catch (UnsupportedEncodingException | NoSuchAlgorithmException grex) {
|
||||||
System.out.println(grex.getMessage());
|
System.out.println(grex.getMessage());
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Error reading in file to hash: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultString;
|
return resultString;
|
||||||
|
@ -16,17 +16,25 @@ This tool will generate a root RIM file for PC clients in accordance with the sc
|
|||||||
%prep
|
%prep
|
||||||
%setup -q -c -n %{name}
|
%setup -q -c -n %{name}
|
||||||
|
|
||||||
|
%pre
|
||||||
|
rm -f /opt/hirs/rimtool/%{name}*.jar
|
||||||
|
|
||||||
%build
|
%build
|
||||||
./gradlew build
|
./gradlew build
|
||||||
|
|
||||||
%install
|
%install
|
||||||
mkdir -p %{buildroot}/opt/hirs/rim/
|
mkdir -p %{buildroot}/opt/hirs/rimtool/
|
||||||
cp build/libs/%{name}-%{version}.jar %{buildroot}/opt/hirs/rim/
|
cp build/libs/%{name}-%{version}.jar %{buildroot}/opt/hirs/rimtool/
|
||||||
|
cp ./rim_fields.json %{buildroot}/opt/hirs/rimtool/
|
||||||
|
cp ./keystore.jks %{buildroot}/opt/hirs/rimtool/
|
||||||
|
|
||||||
%files
|
%files
|
||||||
/opt/hirs/rim/%{name}-%{version}.jar
|
/opt/hirs/rimtool/%{name}-%{version}.jar
|
||||||
|
/opt/hirs/rimtool/rim_fields.json
|
||||||
|
/opt/hirs/rimtool/keystore.jks
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jun 15 2020 chubtub
|
||||||
|
- First release
|
||||||
* Mon Jan 6 2020 chubtub
|
* Mon Jan 6 2020 chubtub
|
||||||
- First change
|
- First change
|
||||||
|
Loading…
x
Reference in New Issue
Block a user