Merge branch 'master' of gitlab.com:MasterPassword/MasterPassword
This commit is contained in:
commit
cc583c789d
@ -1,5 +1,29 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="NullableNotNullManager">
|
||||||
|
<option name="myDefaultNullable" value="javax.annotation.Nullable" />
|
||||||
|
<option name="myDefaultNotNull" value="javax.annotation.Nonnull" />
|
||||||
|
<option name="myNullables">
|
||||||
|
<value>
|
||||||
|
<list size="4">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||||
|
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="myNotNulls">
|
||||||
|
<value>
|
||||||
|
<list size="4">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||||
|
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
|
@ -77,18 +77,28 @@ library {
|
|||||||
|
|
||||||
static String standardOperatingSystem(NativePlatform platform) {
|
static String standardOperatingSystem(NativePlatform platform) {
|
||||||
OperatingSystem os = platform.getOperatingSystem()
|
OperatingSystem os = platform.getOperatingSystem()
|
||||||
if (os.isWindows()) {
|
if (os.isWindows())
|
||||||
return OperatingSystemFamily.WINDOWS
|
return OperatingSystemFamily.WINDOWS
|
||||||
} else if (os.isLinux()) {
|
else if (os.isMacOsX())
|
||||||
return OperatingSystemFamily.LINUX
|
|
||||||
} else if (os.isMacOsX()) {
|
|
||||||
return OperatingSystemFamily.MAC_OS
|
return OperatingSystemFamily.MAC_OS
|
||||||
}
|
else if (os.isLinux())
|
||||||
|
return OperatingSystemFamily.LINUX
|
||||||
|
|
||||||
return os.name.toLowerCase()
|
// Other systems will need to use a Linux compatibility layer for now.
|
||||||
|
return OperatingSystemFamily.LINUX
|
||||||
}
|
}
|
||||||
|
|
||||||
static String standardArchitecture(NativePlatform platform) {
|
static String standardArchitecture(NativePlatform platform) {
|
||||||
Architecture arch = platform.getArchitecture()
|
Architecture arch = platform.getArchitecture()
|
||||||
return arch.name.toLowerCase().replaceAll( "-", "_" )
|
if (arch.isArm())
|
||||||
|
return "arm"
|
||||||
|
else if (arch.name.toLowerCase( Locale.ROOT ).startsWith( "arm" ))
|
||||||
|
return "arm64"
|
||||||
|
else if (arch.isAmd64())
|
||||||
|
return "x86_64"
|
||||||
|
else if (arch.isI386())
|
||||||
|
return "x86"
|
||||||
|
|
||||||
|
// Other systems will need to be compatible with the x86 architecture.
|
||||||
|
return "x86"
|
||||||
}
|
}
|
||||||
|
@ -66,18 +66,20 @@ const char **mpw_strings(size_t *count, const char *strings, ...) {
|
|||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start( args, strings );
|
va_start( args, strings );
|
||||||
char **array = NULL;
|
const char **array = NULL;
|
||||||
size_t arraySize = 0;
|
size_t size = 0;
|
||||||
for (const char *string; string = va_arg( args, const char * );) {
|
for (const char *string = strings; string; (string = va_arg( args, const char * ))) {
|
||||||
size_t cursor = arraySize;
|
size_t cursor = size / sizeof( *array );
|
||||||
if (!mpw_realloc( &array, &arraySize, sizeof(string) )) {
|
if (!mpw_realloc( &array, &size, sizeof( string ) )) {
|
||||||
mpw_free( &array, arraySize );
|
mpw_free( &array, size );
|
||||||
|
*count = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
array[cursor] = string;
|
array[cursor] = string;
|
||||||
}
|
}
|
||||||
va_end( args );
|
va_end( args );
|
||||||
|
|
||||||
|
*count = size / sizeof( *array );
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +313,7 @@ static uint8_t const *mpw_aes(bool encrypt, const uint8_t *key, const size_t key
|
|||||||
AES_CBC_encrypt_buffer( resultBuf, aesBuf, aesSize, key, iv );
|
AES_CBC_encrypt_buffer( resultBuf, aesBuf, aesSize, key, iv );
|
||||||
else
|
else
|
||||||
AES_CBC_decrypt_buffer( resultBuf, aesBuf, aesSize, key, iv );
|
AES_CBC_decrypt_buffer( resultBuf, aesBuf, aesSize, key, iv );
|
||||||
mpw_free( aesBuf, aesSize );
|
mpw_free( &aesBuf, aesSize );
|
||||||
|
|
||||||
// Truncate PKCS#7 padding
|
// Truncate PKCS#7 padding
|
||||||
if (encrypt)
|
if (encrypt)
|
||||||
@ -516,14 +518,11 @@ char *mpw_strndup(const char *src, size_t max) {
|
|||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
int *mpw_strncasecmp(const char *s1, const char *s2, size_t max) {
|
int mpw_strncasecmp(const char *s1, const char *s2, size_t max) {
|
||||||
|
|
||||||
if (s1 && s2 && max)
|
int cmp = 0;
|
||||||
for (; --max > 0; ++s1, ++s2) {
|
for (; !cmp && max-- > 0 && s1 && s2; ++s1, ++s2)
|
||||||
int cmp = tolower( *(unsigned char *)s1 ) - tolower( *(unsigned char *)s2 );
|
cmp = tolower( *(unsigned char *)s1 ) - tolower( *(unsigned char *)s2 );
|
||||||
if (!cmp || *s1 == '\0')
|
|
||||||
return cmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return cmp;
|
||||||
}
|
}
|
@ -118,9 +118,9 @@ bool mpw_push_int(
|
|||||||
/** Reallocate the given buffer from the given size by adding the delta size.
|
/** Reallocate the given buffer from the given size by adding the delta size.
|
||||||
* On success, the buffer size pointer will be updated to the buffer's new size
|
* On success, the buffer size pointer will be updated to the buffer's new size
|
||||||
* and the buffer pointer may be updated to a new memory address.
|
* and the buffer pointer may be updated to a new memory address.
|
||||||
* On failure, the buffer and pointers will remain unaffected.
|
* On failure, the pointers will remain unaffected.
|
||||||
* @param buffer A pointer to the buffer to reallocate.
|
* @param buffer A pointer to the buffer to reallocate.
|
||||||
* @param bufferSize A pointer to the buffer's actual size.
|
* @param bufferSize A pointer to the buffer's current size.
|
||||||
* @param deltaSize The amount to increase the buffer's size by.
|
* @param deltaSize The amount to increase the buffer's size by.
|
||||||
* @return true if successful, false if reallocation failed.
|
* @return true if successful, false if reallocation failed.
|
||||||
*/
|
*/
|
||||||
@ -216,6 +216,6 @@ char *mpw_strdup(const char *src);
|
|||||||
/** Drop-in for POSIX strndup(3). */
|
/** Drop-in for POSIX strndup(3). */
|
||||||
char *mpw_strndup(const char *src, size_t max);
|
char *mpw_strndup(const char *src, size_t max);
|
||||||
/** Drop-in for POSIX strncasecmp(3). */
|
/** Drop-in for POSIX strncasecmp(3). */
|
||||||
int *mpw_strncasecmp(const char *s1, const char *s2, size_t max);
|
int mpw_strncasecmp(const char *s1, const char *s2, size_t max);
|
||||||
|
|
||||||
#endif // _MPW_UTIL_H
|
#endif // _MPW_UTIL_H
|
||||||
|
@ -18,12 +18,16 @@
|
|||||||
|
|
||||||
package com.lyndir.masterpassword.impl;
|
package com.lyndir.masterpassword.impl;
|
||||||
|
|
||||||
|
import static com.lyndir.lhunath.opal.system.util.ObjectUtils.*;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.lyndir.lhunath.opal.system.logging.Logger;
|
import com.lyndir.lhunath.opal.system.logging.Logger;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +49,8 @@ public final class Native {
|
|||||||
try {
|
try {
|
||||||
System.loadLibrary( name );
|
System.loadLibrary( name );
|
||||||
return;
|
return;
|
||||||
} catch (@SuppressWarnings("ErrorNotRethrown") final UnsatisfiedLinkError ignored) {
|
}
|
||||||
|
catch (@SuppressWarnings("ErrorNotRethrown") final UnsatisfiedLinkError ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find and open a stream to the packaged library resource.
|
// Try to find and open a stream to the packaged library resource.
|
||||||
@ -82,10 +87,26 @@ public final class Native {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private static String getLibraryResource(final String library) {
|
private static String getLibraryResource(final String library) {
|
||||||
String system = System.getProperty( "os.name" ).toLowerCase( Locale.ROOT );
|
String system = ifNotNullElse( System.getProperty( "os.name" ), "linux" ).toLowerCase( Locale.ROOT );
|
||||||
String architecture = System.getProperty( "os.arch" ).toLowerCase( Locale.ROOT );
|
String architecture = ifNotNullElse( System.getProperty( "os.arch" ), "x86" ).toLowerCase( Locale.ROOT );
|
||||||
if ("Mac OS X".equalsIgnoreCase( system ))
|
|
||||||
|
// Standardize system naming in accordance with masterpassword-core.
|
||||||
|
if (system.contains( "windows" ))
|
||||||
|
system = "windows";
|
||||||
|
else if (system.contains( "mac os x" ) || system.contains( "darwin" ) || system.contains( "osx" ))
|
||||||
system = "macos";
|
system = "macos";
|
||||||
|
else
|
||||||
|
system = "linux";
|
||||||
|
|
||||||
|
// Standardize architecture naming in accordance with masterpassword-core.
|
||||||
|
if (ImmutableList.of( "arm", "arm-v7", "armv7", "arm32" ).contains( architecture ))
|
||||||
|
architecture = "arm";
|
||||||
|
else if (architecture.startsWith( "arm" ))
|
||||||
|
architecture = "arm64";
|
||||||
|
else if (ImmutableList.of( "x86_64", "amd64", "x64", "x86-64" ).contains( architecture ))
|
||||||
|
architecture = "x86_64";
|
||||||
|
else
|
||||||
|
architecture = "x86";
|
||||||
|
|
||||||
return Joiner.on( RESOURCE_SEPARATOR ).join( "", NATIVES_PATH, system, architecture, library );
|
return Joiner.on( RESOURCE_SEPARATOR ).join( "", NATIVES_PATH, system, architecture, library );
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ dependencies {
|
|||||||
compileOnly group: 'com.google.auto.value', name: 'auto-value', version: '1.2'
|
compileOnly group: 'com.google.auto.value', name: 'auto-value', version: '1.2'
|
||||||
apt group: 'com.google.auto.value', name: 'auto-value', version: '1.2'
|
apt group: 'com.google.auto.value', name: 'auto-value', version: '1.2'
|
||||||
|
|
||||||
testCompile group: 'org.testng', name: 'testng', version: '6.8.5'
|
testImplementation group: 'org.testng', name: 'testng', version: '6.8.5'
|
||||||
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2'
|
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2'
|
||||||
}
|
}
|
||||||
test.useTestNG()
|
test.useTestNG()
|
||||||
|
@ -7,11 +7,11 @@ description = 'Master Password Test Suite'
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation group: 'com.lyndir.lhunath.opal', name: 'opal-system', version: '1.7-p2'
|
implementation group: 'com.lyndir.lhunath.opal', name: 'opal-system', version: '1.7-p2'
|
||||||
|
|
||||||
compile project( ':masterpassword-algorithm' )
|
implementation project( ':masterpassword-algorithm' )
|
||||||
compile project( ':masterpassword-model' )
|
implementation project( ':masterpassword-model' )
|
||||||
|
|
||||||
testCompile group: 'org.testng', name: 'testng', version: '6.8.5'
|
testImplementation group: 'org.testng', name: 'testng', version: '6.8.5'
|
||||||
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2'
|
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2'
|
||||||
}
|
}
|
||||||
//tasks.withType(Test) {
|
//tasks.withType(Test) {
|
||||||
// systemProperty "java.library.path", "/Users/lhunath/Documents/workspace/lyndir/MasterPassword/core/java/algorithm/build/libs/mpw/shared"
|
// systemProperty "java.library.path", "/Users/lhunath/Documents/workspace/lyndir/MasterPassword/core/java/algorithm/build/libs/mpw/shared"
|
||||||
|
Loading…
Reference in New Issue
Block a user