Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 33 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
```
# Compiled Java files
# Compiled and build artifacts
*.class

# Build directories
target/
build/
*.o
*.obj
*.out
*.exe
*.dll
*.so
*.a

# Dependencies
lib/
libs/

# IDE files
.idea/
*.iml
*.ipr
*.iws
target/
.gradle/
**/node_modules/
**/venv/
**/.venv/
**/__pycache__/
**/.mypy_cache/
**/.pytest_cache/

# Logs
# Logs and temp files
*.log
*.tmp
*.swp

# Environment
.env
.env.local
*.env.*

# Temporary files
*.tmp
*.temp
# Editors
.vscode/
.idea/
*.swp
*.swo

# Coverage
coverage/
htmlcov/
.coverage

# System
.DS_Store
Thumbs.db
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.licify.Licify.License;
import com.licify.signing.DigitalSignature;
import com.licify.LicenseKeyPair;
import java.security.KeyPair;

import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -30,10 +31,10 @@ public String generateActivationRequest(License license, String fingerprint) thr
}

// Get key pair from Licify or use default
LicenseKeyPair keyPair = LicenseKeyPair.generate();
KeyPair keyPair = LicenseKeyPair.generateRSAKeys(2048);

String rawData = license.getLicenseKey() + "|" + fingerprint + "|" + System.currentTimeMillis();
String signature = DigitalSignature.signSHA512(rawData, keyPair.getPrivateKey());
String signature = DigitalSignature.signSHA512(rawData, keyPair.getPrivate());

return Base64.getEncoder().encodeToString((rawData + "::" + signature).getBytes());
}
Expand Down Expand Up @@ -71,10 +72,10 @@ public String processActivationResponse(String responseContent) throws Exception
String signature = parts[1];

// Get key pair to verify signature
LicenseKeyPair keyPair = LicenseKeyPair.generate();
KeyPair keyPair = LicenseKeyPair.generateRSAKeys(2048);

// Verify signature using public key
boolean isValid = DigitalSignature.verifySHA512(data, signature, keyPair.getPublicKey());
boolean isValid = DigitalSignature.verifySHA512(data, signature, keyPair.getPublic());

if (!isValid) {
throw new SecurityException("Invalid activation response signature");
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/licify/security/TamperDetection.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.licify.security;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.concurrent.atomic.AtomicInteger;

/**
Expand Down Expand Up @@ -75,16 +73,15 @@ public static boolean detectRapidValidation() {
*/
public static boolean detectDebugger() {
try {
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
long start = threadBean.getCurrentThreadCpuTime();
long start = System.nanoTime();

// Perform a simple operation
int sum = 0;
for (int i = 0; i < 1000; i++) {
sum += i;
}

long end = threadBean.getCurrentThreadCpuTime();
long end = System.nanoTime();
long duration = end - start;

// If the operation takes unusually long, a debugger might be attached
Expand Down
Loading