mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-29 15:44:14 +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 {
|
||||
compile libs.minimal_json
|
||||
compile libs.jcommander
|
||||
compile libs.bouncy_castle
|
||||
testCompile libs.testng
|
||||
compile 'com.eclipsesource.minimal-json:minimal-json:0.9.5', 'com.beust:jcommander:1.72', 'org.bouncycastle:bcmail-jdk15on:1.59'
|
||||
testCompile 'org.testng:testng:6.8.8'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
@ -6,7 +6,7 @@ pushd $SCRIPT_DIR
|
||||
|
||||
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
|
||||
if [ -d rpmbuild ]; then
|
||||
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_PASSWORD = "password";
|
||||
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 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.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
@ -24,8 +26,8 @@ public class HashSwid {
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String get256Hash(String value) {
|
||||
return getHashValue(value, SHA256);
|
||||
public static String get256Hash(String filepath) {
|
||||
return getHashValue(filepath, SHA256);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,8 +35,8 @@ public class HashSwid {
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public String get384Hash(String value) {
|
||||
return getHashValue(value, SHA384);
|
||||
public String get384Hash(String filepath) {
|
||||
return getHashValue(filepath, SHA384);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,24 +44,28 @@ public class HashSwid {
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public String get512Hash(String value) {
|
||||
return getHashValue(value, SHA512);
|
||||
public String get512Hash(String filepath) {
|
||||
return getHashValue(filepath, SHA512);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates the hash based on the provided algorithm and salt
|
||||
* 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 sha the algorithm to use for the hash
|
||||
* @return
|
||||
*/
|
||||
private static String getHashValue(String value, String sha) {
|
||||
private static String getHashValue(String filepath, String sha) {
|
||||
String resultString = null;
|
||||
try {
|
||||
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();
|
||||
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
@ -68,6 +74,8 @@ public class HashSwid {
|
||||
resultString = sb.toString();
|
||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException grex) {
|
||||
System.out.println(grex.getMessage());
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error reading in file to hash: " + e.getMessage());
|
||||
}
|
||||
|
||||
return resultString;
|
||||
|
@ -16,17 +16,25 @@ This tool will generate a root RIM file for PC clients in accordance with the sc
|
||||
%prep
|
||||
%setup -q -c -n %{name}
|
||||
|
||||
%pre
|
||||
rm -f /opt/hirs/rimtool/%{name}*.jar
|
||||
|
||||
%build
|
||||
./gradlew build
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}/opt/hirs/rim/
|
||||
cp build/libs/%{name}-%{version}.jar %{buildroot}/opt/hirs/rim/
|
||||
mkdir -p %{buildroot}/opt/hirs/rimtool/
|
||||
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
|
||||
/opt/hirs/rim/%{name}-%{version}.jar
|
||||
/opt/hirs/rimtool/%{name}-%{version}.jar
|
||||
/opt/hirs/rimtool/rim_fields.json
|
||||
/opt/hirs/rimtool/keystore.jks
|
||||
|
||||
%changelog
|
||||
* Mon Jun 15 2020 chubtub
|
||||
- First release
|
||||
* Mon Jan 6 2020 chubtub
|
||||
- First change
|
||||
|
Loading…
x
Reference in New Issue
Block a user