Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e28b7e273 | ||
|
|
8db4e1b414 | ||
|
|
cafa4f9054 | ||
|
|
71ace783e2 | ||
|
|
d80b8e16f9 | ||
|
|
027b359ed7 | ||
|
|
36e811bf74 |
No files matched your search
@@ -173,9 +173,11 @@ jobs:
|
||||
- name: Run Android input tests
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
api-level: 35
|
||||
api-level: 30
|
||||
arch: x86_64
|
||||
target: google_apis
|
||||
target: default
|
||||
emulator-boot-timeout: 900
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -no-metrics
|
||||
script: make android-input-test
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
|
||||
@@ -161,17 +161,24 @@ jobs:
|
||||
-Pkeystore.alias="$KEY_ALIAS" \
|
||||
-Pkeystore.password="$KEYSTORE_PASSWORD" \
|
||||
--stacktrace
|
||||
VERSION=$(sed -n '1p' VERSION)
|
||||
mkdir -p build/release
|
||||
cp droid/app/build/outputs/apk/release/app-universal-release.apk build/release/pass-android.apk
|
||||
cp droid/app/build/outputs/apk/release/app-arm64-v8a-release.apk build/release/pass-android-arm64-v8a.apk
|
||||
cp droid/app/build/outputs/apk/release/app-armeabi-v7a-release.apk build/release/pass-android-armeabi-v7a.apk
|
||||
cp droid/app/build/outputs/apk/release/app-universal-release.apk "build/release/pass-$VERSION.apk"
|
||||
cp droid/app/build/outputs/apk/release/app-arm64-v8a-release.apk "build/release/pass-$VERSION-arm64-v8a.apk"
|
||||
cp droid/app/build/outputs/apk/release/app-armeabi-v7a-release.apk "build/release/pass-$VERSION-armeabi-v7a.apk"
|
||||
test -s build/release/pass-android.apk
|
||||
test -s build/release/pass-android-arm64-v8a.apk
|
||||
test -s build/release/pass-android-armeabi-v7a.apk
|
||||
test -s "build/release/pass-$VERSION.apk"
|
||||
test -s "build/release/pass-$VERSION-arm64-v8a.apk"
|
||||
test -s "build/release/pass-$VERSION-armeabi-v7a.apk"
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: android
|
||||
path: build/release/pass-android*.apk
|
||||
path: build/release/*.apk
|
||||
if-no-files-found: error
|
||||
|
||||
web:
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# Changelog
|
||||
|
||||
## [0.2.8] - 2026-08-26
|
||||
|
||||
- Match LessPass clients for the same site, login, master password, counter,
|
||||
character classes, and length settings.
|
||||
- Limit password length to LessPass's 5 to 35 character range.
|
||||
- Require Android fingerprint unlock for saved master passwords and store them
|
||||
with an authenticated Android Keystore key.
|
||||
- Use the Sweet Material palette by default, with Sweet-Dark matched colors in
|
||||
dark mode, and show generated passwords in a dedicated output field.
|
||||
- Keep settings controls fully scrollable above the bottom navigation and use
|
||||
the available form width while scrolling.
|
||||
- Keep theme dropdowns from opening the Android soft keyboard.
|
||||
|
||||
## [0.2.7] - 2026-08-24
|
||||
|
||||
- Fix Android source builds in stricter environments such as F-Droid builders
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.PHONY: all cli kry-c gui native run test native-test cli-test check-submodule-urls kry-smoke web web-canvas site web-smoke android-debug android-smoke android-input-test e2e install install-cli uninstall-cli install-gui uninstall-gui package-deb package-appimage
|
||||
.PHONY: all cli kry-c gui native run test native-test cli-test lesspass-compat-test check-submodule-urls kry-smoke web web-canvas site web-smoke android-debug android-smoke android-input-test e2e install install-cli uninstall-cli install-gui uninstall-gui package-deb package-appimage
|
||||
|
||||
BIN_DIR ?= $(HOME)/bin
|
||||
DATA_DIR ?= $(if $(XDG_DATA_HOME),$(XDG_DATA_HOME),$(HOME)/.local/share)
|
||||
@@ -25,7 +25,7 @@ WEB_APP_EMBEDDED_ASSETS_C := build/web/pass_embedded_assets.c
|
||||
WEB_APP_ASSETS := vendor/kryon/fonts/noto/NotoSans-Regular.ttf assets/fonts/emoji.ttf
|
||||
KRYON_ICON_ASSETS_C := vendor/kryon/src/ui/ui_icon_assets.c
|
||||
KRYON_WEB_SRCS_ALL := $(filter-out $(KRYON_ICON_ASSETS_C),$(shell find vendor/kryon/src -type f -name '*.c' | LC_ALL=C sort)) $(KRYON_ICON_ASSETS_C)
|
||||
KRYON_WEB_SRCS := $(filter-out vendor/kryon/src/backend/libdraw_% vendor/kryon/src/file_dialog/file_dialog.c vendor/kryon/src/ksync/% vendor/kryon/src/runtime_assets/% vendor/kryon/src/notification/% vendor/kryon/src/platform/plan9/% vendor/kryon/src/scene/physics_world.c vendor/kryon/src/scene/node_body2d.c vendor/kryon/src/scene/node_area2d.c vendor/kryon/src/scene/node_collision_shape2d.c,$(KRYON_WEB_SRCS_ALL))
|
||||
KRYON_WEB_SRCS := $(filter-out vendor/kryon/src/backend/libdraw_% vendor/kryon/src/backend/termi_% vendor/kryon/src/file_dialog/file_dialog.c vendor/kryon/src/ksync/% vendor/kryon/src/runtime_assets/% vendor/kryon/src/notification/% vendor/kryon/src/platform/plan9/% vendor/kryon/src/scene/physics_world.c vendor/kryon/src/scene/node_body2d.c vendor/kryon/src/scene/node_area2d.c vendor/kryon/src/scene/node_collision_shape2d.c,$(KRYON_WEB_SRCS_ALL))
|
||||
PASS_WEB_SRCS := droid/app/src/main/cpp/main.c droid/app/src/main/cpp/android_bridge.c native/pass_core.c native/pass_runtime.c $(KRY_C_APP_SRCS) $(WEB_APP_EMBEDDED_ASSETS_C)
|
||||
WEB_CFLAGS := -Wall -Wextra -std=gnu99 -Os -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -D_DEFAULT_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DUI_EMBEDDED_ONLY=1 -DKRYON_WITH_PHYSICS=0 -Ivendor/kryon/include -Ivendor/kryon/src -I$(KRY_C_GENERATED_DIR) -Inative -Idroid/app/src/main/cpp
|
||||
WEB_LDFLAGS := -sASYNCIFY -sASYNCIFY_STACK_SIZE=1048576 -sFORCE_FILESYSTEM=1 -sFETCH=1 -sALLOW_MEMORY_GROWTH=1 -sINITIAL_MEMORY=134217728 -sSTACK_SIZE=16777216 -lidbfs.js -lm
|
||||
@@ -95,7 +95,7 @@ uninstall-gui:
|
||||
rm -f $(BIN_DIR)/pass-gui $(DATA_DIR)/applications/xyz.waozi.pass.desktop $(DATA_DIR)/icons/hicolor/512x512/apps/pass.png
|
||||
|
||||
test:
|
||||
$(MAKE) native-test cli-test kry-smoke
|
||||
$(MAKE) native-test cli-test lesspass-compat-test kry-smoke
|
||||
|
||||
# Checks the C generator used by the CLI and every Kry app target.
|
||||
native-test:
|
||||
@@ -104,8 +104,11 @@ native-test:
|
||||
./build/pass_core_test
|
||||
|
||||
cli-test: cli
|
||||
test "$$(./pass example.com alice 'correct horse battery staple')" = "&vLf44D'/cSkP-_8"
|
||||
test "$$(./pass --length 20 --counter 2 service.test [email protected] master)" = "j:x_Lo5X_jL0w%ez\`1be"
|
||||
test "$$(./pass lesspass.com [email protected] password)" = '\g-A1-.OHEwrXjT#'
|
||||
test "$$(./pass --length 20 --counter 2 service.test [email protected] master)" = 'j:x_Lo5b1XL_j0we%z`e'
|
||||
|
||||
lesspass-compat-test: cli
|
||||
python3 scripts/lesspass_compat_test.py --cli ./pass
|
||||
|
||||
check-submodule-urls:
|
||||
bash scripts/check_submodule_urls.sh
|
||||
|
||||
@@ -25,7 +25,8 @@ pass [OPTIONS] SITE LOGIN [MASTER_PASSWORD]
|
||||
```
|
||||
|
||||
The default password has 16 characters and includes lowercase letters,
|
||||
uppercase letters, digits, and symbols. The default counter is 1.
|
||||
uppercase letters, digits, and symbols. Length must be between 5 and 35,
|
||||
matching LessPass clients. The default counter is 1.
|
||||
|
||||
Passing a master password as an argument can expose it to process inspection
|
||||
and shell history. Omitting it is safer: `pass` first checks
|
||||
|
||||
+33
-10
@@ -49,9 +49,9 @@ state {
|
||||
auto_copy: int = 0
|
||||
clear_seconds: int = 20
|
||||
show_fingerprint: int = 1
|
||||
theme_source: int = THEME_SOURCE_SYSTEM
|
||||
theme_source: int = THEME_SOURCE_APP
|
||||
theme_mode: int = THEME_MODE_SYSTEM
|
||||
theme_id: int = THEME_MINT
|
||||
theme_id: int = THEME_SWEET
|
||||
theme_style: int = THEME_STYLE_MATERIAL
|
||||
theme_menu_state: UIThemeSettingsState
|
||||
|
||||
@@ -153,6 +153,22 @@ pass_draw_master_emoji :: (x: int, y: int, master_text: [1024] char, enabled: in
|
||||
return ScaleUIPx(32)
|
||||
}
|
||||
|
||||
pass_draw_generated_output :: (x: int, y: int, width: int) #private {
|
||||
bounds := (Rectangle){x, y, width, ScaleUIPx(54)}
|
||||
inner := (Rectangle){x + ScaleUIPx(14), y + ScaleUIPx(9), width - ScaleUIPx(28), ScaleUIPx(36)}
|
||||
output: char* = pass_generated()
|
||||
border: Color = Fade(GetThemeIcon(), 0.30f)
|
||||
fill: Color = GetThemeSurface()
|
||||
|
||||
DrawRectangleRounded(bounds, 0.12f, 10, fill)
|
||||
DrawRectangleRoundedLinesEx(bounds, 0.12f, 10, ScaleUIPx(1), border)
|
||||
if output[0] == 0 {
|
||||
TextInRect("Password will appear here", inner, Text16, Fade(GetThemeText(), 0.54f))
|
||||
} else {
|
||||
TextInRect(output, inner, Text16, GetThemeText())
|
||||
}
|
||||
}
|
||||
|
||||
pass_request_focused_input_visible :: (focus_id: int, bounds: Rectangle) #private {
|
||||
if IsUIFocusActive(focus_id) == 0 {
|
||||
if pass_visible_focus_id == focus_id {
|
||||
@@ -234,7 +250,7 @@ pass_draw_generate :: (pad: int, y: int, content_w: int) -> int #private {
|
||||
y += ScaleUIPx(12)
|
||||
|
||||
Text("Length", pad, y + ScaleUIPx(10), Text16, GetThemeText())
|
||||
Spinbox((SpinboxProps){.bounds = {pad + content_w - ScaleUIPx(156), y, ScaleUIPx(156), ScaleUIPx(40)}, .id = 20, .min = 4, .max = 128, .step = 1, .value = &length, .disabled = 0, .wrap = 0})
|
||||
Spinbox((SpinboxProps){.bounds = {pad + content_w - ScaleUIPx(156), y, ScaleUIPx(156), ScaleUIPx(40)}, .id = 20, .min = 5, .max = 35, .step = 1, .value = &length, .disabled = 0, .wrap = 0})
|
||||
y += ScaleUIPx(54)
|
||||
|
||||
Text("Counter", pad, y + ScaleUIPx(10), Text16, GetThemeText())
|
||||
@@ -262,12 +278,12 @@ pass_draw_generate :: (pad: int, y: int, content_w: int) -> int #private {
|
||||
y += ScaleUIPx(60)
|
||||
|
||||
Text("Generated password", pad, y, Text14, GetThemeText())
|
||||
TextInRect(pass_generated(), (Rectangle){pad, y + ScaleUIPx(22), content_w, ScaleUIPx(48)}, Text16, GetThemeText())
|
||||
pass_draw_generated_output(pad, y + ScaleUIPx(22), content_w)
|
||||
if pass_scroll_to_generated == 1 {
|
||||
pass_request_rect_visible((Rectangle){pad, y, content_w, ScaleUIPx(76)})
|
||||
pass_request_rect_visible((Rectangle){pad, y, content_w, ScaleUIPx(82)})
|
||||
pass_scroll_to_generated = 0
|
||||
}
|
||||
y += ScaleUIPx(82)
|
||||
y += ScaleUIPx(88)
|
||||
|
||||
if Button((ButtonProps){.bounds = {pad, y, content_w, ScaleUIPx(40)}, .label = "Copy", .style = ButtonStyleSecondary, .font = Text16, .id = 41}) {
|
||||
pass_copy()
|
||||
@@ -313,6 +329,7 @@ pass_frame :: () #ui {
|
||||
|
||||
nav_h: int = ScaleUIPx(66)
|
||||
nav_y: int = screen_h - bottom - nav_h
|
||||
scrollbar_x: int = screen_w - ScaleUIPx(pass_safe_right()) - ScaleUIPx(8)
|
||||
y: int = top
|
||||
view_h: int = nav_y - y
|
||||
if view_h < ScaleUIPx(180) {
|
||||
@@ -324,7 +341,9 @@ pass_frame :: () #ui {
|
||||
area := (UIScrollArea){
|
||||
.bounds = {left, y, content_w, view_h},
|
||||
.content_height = pass_generate_content_height(),
|
||||
.scroll_offset = &generate_scroll
|
||||
.scroll_offset = &generate_scroll,
|
||||
.content_width = content_w,
|
||||
.scrollbar_x = scrollbar_x
|
||||
}
|
||||
scroll := BeginUIScrollContainer(area)
|
||||
pass_draw_generate(scroll.content_x, scroll.content_y, scroll.content_w)
|
||||
@@ -334,7 +353,9 @@ pass_frame :: () #ui {
|
||||
area := (UIScrollArea){
|
||||
.bounds = {left, y, content_w, view_h},
|
||||
.content_height = profiles_content_height(),
|
||||
.scroll_offset = &profiles_scroll
|
||||
.scroll_offset = &profiles_scroll,
|
||||
.content_width = content_w,
|
||||
.scrollbar_x = scrollbar_x
|
||||
}
|
||||
scroll := BeginUIScrollContainer(area)
|
||||
pass_draw_profiles(scroll.content_x, scroll.content_y, scroll.content_w)
|
||||
@@ -343,8 +364,10 @@ pass_frame :: () #ui {
|
||||
} else {
|
||||
area := (UIScrollArea){
|
||||
.bounds = {left, y, content_w, view_h},
|
||||
.content_height = settings_content_height(),
|
||||
.scroll_offset = &settings_scroll
|
||||
.content_height = settings_content_height(master),
|
||||
.scroll_offset = &settings_scroll,
|
||||
.content_width = content_w,
|
||||
.scrollbar_x = scrollbar_x
|
||||
}
|
||||
scroll := BeginUIScrollContainer(area)
|
||||
settings_draw(scroll.content_x, scroll.content_y, scroll.content_w, master, &master_cursor, &reveal_master, &auto_copy, &clear_seconds, &show_fingerprint, &length, &counter, &lower, &upper, &digits, &symbols, exclude, &exclude_cursor, &theme_source, &theme_mode, &theme_id, &theme_style)
|
||||
|
||||
+24
-3
@@ -74,7 +74,7 @@ settings_draw :: (
|
||||
y += ScaleUIPx(34)
|
||||
|
||||
Text("Length", x, y + ScaleUIPx(10), Text16, GetThemeText())
|
||||
Spinbox((SpinboxProps){.bounds = {x + width - ScaleUIPx(156), y, ScaleUIPx(156), ScaleUIPx(40)}, .id = 504, .min = 4, .max = 128, .step = 1, .value = length, .disabled = 0, .wrap = 0})
|
||||
Spinbox((SpinboxProps){.bounds = {x + width - ScaleUIPx(156), y, ScaleUIPx(156), ScaleUIPx(40)}, .id = 504, .min = 5, .max = 35, .step = 1, .value = length, .disabled = 0, .wrap = 0})
|
||||
y += ScaleUIPx(54)
|
||||
|
||||
Text("Counter", x, y + ScaleUIPx(10), Text16, GetThemeText())
|
||||
@@ -143,8 +143,29 @@ settings_theme_modal_is_open :: () -> int {
|
||||
return settings_theme_modal_open
|
||||
}
|
||||
|
||||
settings_content_height :: () -> int {
|
||||
return ScaleUIPx(940)
|
||||
settings_content_height :: (master: [1024] char) -> int {
|
||||
height: int = 0
|
||||
|
||||
height += ScaleUIPx(42)
|
||||
height += ScaleUIPx(52)
|
||||
height += ScaleUIPx(52)
|
||||
height += ScaleUIPx(34)
|
||||
height += ScaleUIPx(54)
|
||||
height += ScaleUIPx(58)
|
||||
height += ScaleUIPx(72)
|
||||
height += ScaleUIPx(76)
|
||||
height += ScaleUIPx(60)
|
||||
height += ScaleUIPx(34)
|
||||
height += ScaleUIPx(64)
|
||||
if master[0] != 0 {
|
||||
height += ScaleUIPx(32)
|
||||
}
|
||||
height += ScaleUIPx(12)
|
||||
height += ScaleUIPx(30)
|
||||
height += ScaleUIPx(60)
|
||||
height += ScaleUIPx(52)
|
||||
|
||||
return height
|
||||
}
|
||||
|
||||
settings_draw_theme_modal :: (
|
||||
|
||||
@@ -7,6 +7,10 @@ android {
|
||||
compileSdk 36
|
||||
ndkVersion "28.2.13676358"
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += '../../vendor/kryon/src/platform/android/java'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -47,8 +51,8 @@ android {
|
||||
applicationId 'xyz.waozi.pass'
|
||||
minSdk 21
|
||||
targetSdk 36
|
||||
versionCode 8
|
||||
versionName "0.2.7"
|
||||
versionCode 9
|
||||
versionName "0.2.8"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
// Default to the two realistic phone targets; override with
|
||||
// -Pabi=x86_64 etc. for emulator builds.
|
||||
|
||||
@@ -99,6 +99,7 @@ add_library(main SHARED
|
||||
"${PASS_NATIVE_DIR}/pass_runtime.c"
|
||||
${PASS_KRY_GENERATED_SOURCES}
|
||||
"${PASS_EMBEDDED_ASSETS_C}"
|
||||
"${KRYON_DIR}/src/backend/kry_sw_png.c"
|
||||
${KRYON_SOURCES}
|
||||
"${NATIVE_APP_GLUE_DIR}/android_native_app_glue.c"
|
||||
)
|
||||
|
||||
@@ -1,34 +1,18 @@
|
||||
package xyz.waozi.pass;
|
||||
|
||||
import android.app.NativeActivity;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.biometrics.BiometricPrompt;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
import android.security.keystore.UserNotAuthenticatedException;
|
||||
import android.security.keystore.KeyGenParameterSpec;
|
||||
import android.security.keystore.KeyProperties;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowInsets;
|
||||
import android.content.Context;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.GCMParameterSpec;
|
||||
import com.kryonlabs.kryon.SecureStore;
|
||||
|
||||
/**
|
||||
* NativeActivity glue for the kryon UI: routes soft-keyboard input and
|
||||
@@ -36,17 +20,6 @@ import javax.crypto.spec.GCMParameterSpec;
|
||||
*/
|
||||
public class MainActivity extends NativeActivity {
|
||||
private static final String SECURE_PREFS = "pass_secure";
|
||||
private static final String KEY_ALIAS_LEGACY = "pass_master_key";
|
||||
private static final String KEY_ALIAS_PLAIN = "pass_master_key_plain";
|
||||
private static final String KEY_ALIAS_AUTH = "pass_master_key_auth";
|
||||
private static final String PREF_CIPHERTEXT = "master_ciphertext";
|
||||
private static final String PREF_IV = "master_iv";
|
||||
private static final String PREF_BIOMETRIC = "master_biometric";
|
||||
private static final String PREF_KEY_ALIAS = "master_key_alias";
|
||||
private static final int SECURE_IDLE = 0;
|
||||
private static final int SECURE_PENDING = 1;
|
||||
private static final int SECURE_OK = 2;
|
||||
private static final int SECURE_ERROR = 3;
|
||||
|
||||
static {
|
||||
// Associate libmain with this class's loader so ART can resolve the
|
||||
@@ -55,8 +28,9 @@ public class MainActivity extends NativeActivity {
|
||||
}
|
||||
|
||||
private final Object secureLock = new Object();
|
||||
private int secureStatus = SECURE_IDLE;
|
||||
private int secureStatus = SecureStore.STATUS_IDLE;
|
||||
private String secureResult = "";
|
||||
private SecureStore secureStore;
|
||||
private TextInputBridge textInputBridge;
|
||||
|
||||
private native void nativeSetInsets(int left, int top, int right, int bottom,
|
||||
@@ -72,6 +46,7 @@ public class MainActivity extends NativeActivity {
|
||||
applySystemBars();
|
||||
setupInsetsListener();
|
||||
setupTextInputBridge();
|
||||
secureStore = new SecureStore(this, SECURE_PREFS, "pass_master_key");
|
||||
}
|
||||
|
||||
public int[] systemThemeColors() {
|
||||
@@ -130,36 +105,19 @@ public class MainActivity extends NativeActivity {
|
||||
}
|
||||
|
||||
public boolean hasStoredMasterPassword() {
|
||||
SharedPreferences prefs = getSharedPreferences(SECURE_PREFS, MODE_PRIVATE);
|
||||
return prefs.contains(PREF_CIPHERTEXT) && prefs.contains(PREF_IV);
|
||||
return secureStore != null && secureStore.hasStoredSecret();
|
||||
}
|
||||
|
||||
public boolean isStoredMasterBiometric() {
|
||||
return getSharedPreferences(SECURE_PREFS, MODE_PRIVATE).getBoolean(PREF_BIOMETRIC, false);
|
||||
return hasStoredMasterPassword();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isBiometricAvailable() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false;
|
||||
try {
|
||||
FingerprintManager fm = (FingerprintManager)getSystemService(Context.FINGERPRINT_SERVICE);
|
||||
if (fm != null && fm.isHardwareDetected() && fm.hasEnrolledFingerprints()) return true;
|
||||
} catch (SecurityException ignored) {
|
||||
}
|
||||
return false;
|
||||
return secureStore != null && secureStore.isBiometricAvailable();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isBiometricSetupRequired() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false;
|
||||
try {
|
||||
FingerprintManager fm = (FingerprintManager)getSystemService(Context.FINGERPRINT_SERVICE);
|
||||
if (fm == null || !fm.isHardwareDetected()) return false;
|
||||
KeyguardManager km = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
|
||||
return !fm.hasEnrolledFingerprints() || km == null || !km.isDeviceSecure();
|
||||
} catch (SecurityException ignored) {
|
||||
return false;
|
||||
}
|
||||
return secureStore != null && secureStore.isBiometricSetupRequired();
|
||||
}
|
||||
|
||||
private String biometricUnavailableMessage() {
|
||||
@@ -170,16 +128,20 @@ public class MainActivity extends NativeActivity {
|
||||
}
|
||||
|
||||
public int secureMasterStatus() {
|
||||
if (secureStore != null)
|
||||
return secureStore.status();
|
||||
synchronized (secureLock) {
|
||||
return secureStatus;
|
||||
}
|
||||
}
|
||||
|
||||
public String takeSecureMasterResult() {
|
||||
if (secureStore != null)
|
||||
return secureStore.takeResult();
|
||||
synchronized (secureLock) {
|
||||
String value = secureResult == null ? "" : secureResult;
|
||||
secureResult = "";
|
||||
secureStatus = SECURE_IDLE;
|
||||
secureStatus = SecureStore.STATUS_IDLE;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -192,217 +154,46 @@ public class MainActivity extends NativeActivity {
|
||||
setSecureError("Enter a master password first");
|
||||
return;
|
||||
}
|
||||
if (requireBiometric && !isBiometricAvailable()) {
|
||||
if (!isBiometricAvailable()) {
|
||||
setSecureError(biometricUnavailableMessage());
|
||||
return;
|
||||
}
|
||||
if (requireBiometric) {
|
||||
authenticateThenSave(master);
|
||||
} else {
|
||||
encryptAndStoreMaster(master, false);
|
||||
}
|
||||
if (secureStore != null)
|
||||
secureStore.saveSecret(master, "master password");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void unlockMasterPassword() {
|
||||
if (!hasStoredMasterPassword()) {
|
||||
if (secureStore == null || !hasStoredMasterPassword()) {
|
||||
setSecureError("No saved master password");
|
||||
return;
|
||||
}
|
||||
if (isStoredMasterBiometric()) {
|
||||
authenticateThenDecrypt();
|
||||
return;
|
||||
}
|
||||
decryptStoredMaster();
|
||||
secureStore.unlockSecret("master password");
|
||||
}
|
||||
|
||||
public void clearMasterPassword() {
|
||||
getSharedPreferences(SECURE_PREFS, MODE_PRIVATE).edit().clear().apply();
|
||||
setSecureOk("Saved master password removed");
|
||||
}
|
||||
|
||||
private void authenticateThenDecrypt() {
|
||||
promptForBiometric("Unlock master password",
|
||||
"Use your fingerprint",
|
||||
"pass will decrypt the saved master password after unlock",
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
decryptStoredMaster();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void authenticateThenSave(final String master) {
|
||||
promptForBiometric("Save master password",
|
||||
"Use your fingerprint",
|
||||
"pass will require fingerprint unlock for the saved master password",
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
encryptAndStoreMaster(master, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void promptForBiometric(String title, String subtitle, String description,
|
||||
final Runnable onSuccess) {
|
||||
if (!isBiometricAvailable()) {
|
||||
setSecureError(biometricUnavailableMessage());
|
||||
return;
|
||||
if (secureStore != null) {
|
||||
secureStore.clearSecret();
|
||||
} else {
|
||||
setSecureOk("Saved master password removed");
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
setSecureError("Biometric prompt requires Android 9 or newer");
|
||||
return;
|
||||
}
|
||||
synchronized (secureLock) {
|
||||
secureStatus = SECURE_PENDING;
|
||||
secureResult = "";
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Executor executor = new Executor() {
|
||||
@Override
|
||||
public void execute(Runnable command) {
|
||||
runOnUiThread(command);
|
||||
}
|
||||
};
|
||||
BiometricPrompt prompt = new BiometricPrompt.Builder(MainActivity.this)
|
||||
.setTitle(title)
|
||||
.setSubtitle(subtitle)
|
||||
.setDescription(description)
|
||||
.setNegativeButton("Cancel", executor, (dialog, which) -> setSecureError("Canceled"))
|
||||
.build();
|
||||
prompt.authenticate(new CancellationSignal(), executor,
|
||||
new BiometricPrompt.AuthenticationCallback() {
|
||||
@Override
|
||||
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
|
||||
onSuccess.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationError(int errorCode, CharSequence errString) {
|
||||
setSecureError(errString == null ? "Unlock failed" : errString.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailed() {
|
||||
setSecureError("Biometric unlock failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void encryptAndStoreMaster(String master, boolean requireBiometric) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, getOrCreateMasterKey(requireBiometric));
|
||||
byte[] encrypted = cipher.doFinal(master.getBytes(StandardCharsets.UTF_8));
|
||||
byte[] iv = cipher.getIV();
|
||||
if (iv == null || iv.length == 0) {
|
||||
setSecureError("Save failed: missing encryption IV");
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences.Editor editor = getSharedPreferences(SECURE_PREFS, MODE_PRIVATE).edit();
|
||||
editor.putString(PREF_IV, b64(iv));
|
||||
editor.putString(PREF_CIPHERTEXT, b64(encrypted));
|
||||
editor.putBoolean(PREF_BIOMETRIC, requireBiometric);
|
||||
editor.putString(PREF_KEY_ALIAS, requireBiometric ? KEY_ALIAS_AUTH : KEY_ALIAS_PLAIN);
|
||||
editor.apply();
|
||||
setSecureOk("Master password saved");
|
||||
} catch (UserNotAuthenticatedException e) {
|
||||
setSecureError("Unlock with fingerprint first");
|
||||
} catch (Exception e) {
|
||||
setSecureError("Save failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void decryptStoredMaster() {
|
||||
try {
|
||||
SharedPreferences prefs = getSharedPreferences(SECURE_PREFS, MODE_PRIVATE);
|
||||
String ivText = prefs.getString(PREF_IV, "");
|
||||
String encryptedText = prefs.getString(PREF_CIPHERTEXT, "");
|
||||
if (ivText.length() == 0 || encryptedText.length() == 0) {
|
||||
setSecureError("No saved master password");
|
||||
return;
|
||||
}
|
||||
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, getStoredMasterKey(), new GCMParameterSpec(128, unb64(ivText)));
|
||||
byte[] decrypted = cipher.doFinal(unb64(encryptedText));
|
||||
setSecureOk(new String(decrypted, StandardCharsets.UTF_8));
|
||||
} catch (UserNotAuthenticatedException e) {
|
||||
setSecureError("Unlock with fingerprint first");
|
||||
} catch (Exception e) {
|
||||
setSecureError("Unlock failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private SecretKey getStoredMasterKey() throws Exception {
|
||||
SharedPreferences prefs = getSharedPreferences(SECURE_PREFS, MODE_PRIVATE);
|
||||
String alias = prefs.getString(PREF_KEY_ALIAS, KEY_ALIAS_LEGACY);
|
||||
boolean requireAuth = KEY_ALIAS_AUTH.equals(alias);
|
||||
return getOrCreateMasterKey(alias, requireAuth);
|
||||
}
|
||||
|
||||
private SecretKey getOrCreateMasterKey(boolean requireAuth) throws Exception {
|
||||
return getOrCreateMasterKey(requireAuth ? KEY_ALIAS_AUTH : KEY_ALIAS_PLAIN, requireAuth);
|
||||
}
|
||||
|
||||
private SecretKey getOrCreateMasterKey(String alias, boolean requireAuth) throws Exception {
|
||||
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
|
||||
keyStore.load(null);
|
||||
if (keyStore.containsAlias(alias)) {
|
||||
return (SecretKey)keyStore.getKey(alias, null);
|
||||
}
|
||||
KeyGenerator generator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
|
||||
KeyGenParameterSpec.Builder spec = new KeyGenParameterSpec.Builder(
|
||||
alias, KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
|
||||
.setBlockModes(KeyProperties.BLOCK_MODE_GCM)
|
||||
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
|
||||
.setRandomizedEncryptionRequired(true);
|
||||
if (requireAuth) {
|
||||
spec.setUserAuthenticationRequired(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
spec.setUserAuthenticationParameters(30,
|
||||
KeyProperties.AUTH_BIOMETRIC_STRONG | KeyProperties.AUTH_DEVICE_CREDENTIAL);
|
||||
} else {
|
||||
spec.setUserAuthenticationValidityDurationSeconds(30);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
spec.setInvalidatedByBiometricEnrollment(true);
|
||||
}
|
||||
}
|
||||
KeyGenParameterSpec builtSpec = spec.build();
|
||||
generator.init(builtSpec);
|
||||
return generator.generateKey();
|
||||
}
|
||||
|
||||
private void setSecureOk(String value) {
|
||||
synchronized (secureLock) {
|
||||
secureStatus = SECURE_OK;
|
||||
secureStatus = SecureStore.STATUS_OK;
|
||||
secureResult = value == null ? "" : value;
|
||||
}
|
||||
}
|
||||
|
||||
private void setSecureError(String value) {
|
||||
synchronized (secureLock) {
|
||||
secureStatus = SECURE_ERROR;
|
||||
secureStatus = SecureStore.STATUS_ERROR;
|
||||
secureResult = value == null ? "Secure storage failed" : value;
|
||||
}
|
||||
}
|
||||
|
||||
private static String b64(byte[] data) {
|
||||
return android.util.Base64.encodeToString(data, android.util.Base64.NO_WRAP);
|
||||
}
|
||||
|
||||
private static byte[] unb64(String text) {
|
||||
return android.util.Base64.decode(text, android.util.Base64.NO_WRAP);
|
||||
}
|
||||
|
||||
private void setupTextInputBridge() {
|
||||
textInputBridge = new TextInputBridge(this, new TextInputBridge.Callbacks() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
- Match LessPass clients for the same site, login, master password, counter, character classes, and length settings.
|
||||
- Limit password length to LessPass's 5 to 35 character range.
|
||||
- Require Android fingerprint unlock for saved master passwords and store them with an authenticated Android Keystore key.
|
||||
- Use the Sweet Material palette by default, with Sweet-Dark matched colors in dark mode, and show generated passwords in a dedicated output field.
|
||||
+1
-1
@@ -30,7 +30,7 @@ usage(FILE *out)
|
||||
"Derive a site-specific password.\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
" -L, --length N password length (default 16)\n"
|
||||
" -L, --length N password length (default 16, min 5, max 35)\n"
|
||||
" -C, --counter N generation counter (default 1)\n"
|
||||
" -l, --lowercase include lowercase letters\n"
|
||||
" -u, --uppercase include uppercase letters\n"
|
||||
|
||||
+11
-4
@@ -412,8 +412,12 @@ pass_core_generate(const char *site, const char *login, const char *master,
|
||||
char message[192];
|
||||
int i;
|
||||
|
||||
if(options->length < 1)
|
||||
return set_error(err, err_size, "password length must be positive");
|
||||
if(options->length < PASS_MIN_LENGTH || options->length > PASS_MAX_LENGTH) {
|
||||
snprintf(message, sizeof(message),
|
||||
"password length must be between %d and %d",
|
||||
PASS_MIN_LENGTH, PASS_MAX_LENGTH);
|
||||
return set_error(err, err_size, message);
|
||||
}
|
||||
|
||||
for(i = 0; i < 4; i++) {
|
||||
if(!class_enabled[i])
|
||||
@@ -439,6 +443,9 @@ pass_core_generate(const char *site, const char *login, const char *master,
|
||||
options->length, class_count);
|
||||
return set_error(err, err_size, message);
|
||||
}
|
||||
if(options->length == class_count)
|
||||
return set_error(err, err_size,
|
||||
"password length must leave room for generated characters");
|
||||
if((size_t)options->length + 1 > out_size || options->length + 1 > (int)sizeof(password))
|
||||
return set_error(err, err_size, "password length exceeds the output buffer");
|
||||
|
||||
@@ -460,7 +467,7 @@ pass_core_generate(const char *site, const char *login, const char *master,
|
||||
salt_len += login_len;
|
||||
}
|
||||
salt_len += (size_t)snprintf(salt + salt_len, sizeof(salt) - salt_len,
|
||||
"%llu", (unsigned long long)options->counter);
|
||||
"%llx", (unsigned long long)options->counter);
|
||||
|
||||
pass_core_derive_key(master != NULL ? master : "", master != NULL ? strlen(master) : 0,
|
||||
salt, salt_len, entropy);
|
||||
@@ -473,7 +480,7 @@ pass_core_generate(const char *site, const char *login, const char *master,
|
||||
required[i] = classes[i][entropy_take_remainder(entropy, class_lengths[i])];
|
||||
|
||||
for(i = 0; i < class_count; i++) {
|
||||
int position = entropy_take_remainder(entropy, password_length + 1);
|
||||
int position = entropy_take_remainder(entropy, password_length);
|
||||
|
||||
memmove(password + position + 1, password + position,
|
||||
(size_t)(password_length - position));
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#define PASS_DERIVATION_ROUNDS 100000
|
||||
#define PASS_MASTER_EMOJI_COUNT 4
|
||||
#define PASS_MIN_LENGTH 5
|
||||
#define PASS_MAX_LENGTH 35
|
||||
|
||||
typedef struct {
|
||||
int length;
|
||||
|
||||
+41
-14
@@ -167,7 +167,7 @@ check_shape(void)
|
||||
int i, j, has_lower, has_upper, has_digits, has_symbols;
|
||||
|
||||
memset(&options, 0, sizeof(options));
|
||||
options.length = 40;
|
||||
options.length = 35;
|
||||
options.counter = 3;
|
||||
options.lowercase = 1;
|
||||
options.uppercase = 1;
|
||||
@@ -180,8 +180,8 @@ check_shape(void)
|
||||
failures++;
|
||||
return;
|
||||
}
|
||||
if((int)strlen(out) != 40) {
|
||||
printf("FAIL shape: length %zu, want 40\n", strlen(out));
|
||||
if((int)strlen(out) != 35) {
|
||||
printf("FAIL shape: length %zu, want 35\n", strlen(out));
|
||||
failures++;
|
||||
return;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ check_shape(void)
|
||||
failures++;
|
||||
return;
|
||||
}
|
||||
printf("ok shape: 40 chars, all classes covered, exclusions honored\n");
|
||||
printf("ok shape: 35 chars, all classes covered, exclusions honored\n");
|
||||
}
|
||||
|
||||
int
|
||||
@@ -223,6 +223,8 @@ main(void)
|
||||
"0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5");
|
||||
check_derive(2, "", "examplealice1",
|
||||
"caa46554f5a676b76c15b368c655b0b24eaaad8595ef919999785c68e60fd5f5");
|
||||
check_derive(3, "test", "sitelogina",
|
||||
"91b368e6337bd9c7007041922ade15c2907bd53c450f73e0ba1a001e10bff7eb");
|
||||
check_sha256();
|
||||
check_master_emoji();
|
||||
|
||||
@@ -236,7 +238,7 @@ main(void)
|
||||
defaults.exclude = "";
|
||||
|
||||
check_generate(1, "example.com", "alice", "correct horse battery staple",
|
||||
defaults, "&vLf44D'/cSkP-_8", 0);
|
||||
defaults, "&Lf4'/-cSk4DPv_8", 0);
|
||||
|
||||
{
|
||||
PassOptions o = defaults;
|
||||
@@ -244,7 +246,7 @@ main(void)
|
||||
o.length = 20;
|
||||
o.counter = 2;
|
||||
check_generate(2, "service.test", "[email protected]", "master",
|
||||
o, "j:x_Lo5X_jL0w%ez`1be", 0);
|
||||
o, "j:x_Lo5b1XL_j0we%z`e", 0);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -257,7 +259,7 @@ main(void)
|
||||
o.digits = 1;
|
||||
check_generate(3, "\xce\xb4\xce\xbf\xce\xba\xce\xb9\xce\xbc\xce\xae.example",
|
||||
"\xe3\x83\xa6\xe3\x83\xbc\xe3\x82\xb6\xe3\x83\xbc",
|
||||
"p\xc3\xa4ssword", o, "ioh5o2mhyghv", 0);
|
||||
"p\xc3\xa4ssword", o, "oih5omhygh2v", 0);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -266,18 +268,36 @@ main(void)
|
||||
o.length = 24;
|
||||
o.exclude = "0Ool1I!|";
|
||||
check_generate(4, "example.com", "alice", "correct horse battery staple",
|
||||
o, "7,a.Cp}YnF'ee7HqbX#PQhgH", 0);
|
||||
o, "7,.Cp}YnF'eeHHaqbX7#PQhg", 0);
|
||||
}
|
||||
|
||||
{
|
||||
PassOptions o;
|
||||
|
||||
memset(&o, 0, sizeof(o));
|
||||
o.length = 4;
|
||||
o.length = 5;
|
||||
o.counter = 0;
|
||||
o.uppercase = 1;
|
||||
o.digits = 1;
|
||||
check_generate(5, "x", "y", "", o, "9O7C", 0);
|
||||
check_generate(5, "x", "y", "", o, "C9O9I", 0);
|
||||
}
|
||||
|
||||
{
|
||||
PassOptions o = defaults;
|
||||
|
||||
check_generate(6, "lesspass.com", "[email protected]", "password",
|
||||
o, "\\g-A1-.OHEwrXjT#", 0);
|
||||
}
|
||||
|
||||
{
|
||||
PassOptions o = defaults;
|
||||
|
||||
o.counter = 10;
|
||||
check_generate(7, "site", "login", "test",
|
||||
o, "XFt0F*,r619:+}[.", 0);
|
||||
o.counter = 16;
|
||||
check_generate(8, "site", "login", "test",
|
||||
o, "l:`nzj>S7+0#uL_d", 0);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -286,7 +306,7 @@ main(void)
|
||||
memset(&o, 0, sizeof(o));
|
||||
o.length = 0;
|
||||
o.lowercase = 1;
|
||||
check_generate(6, "site", "login", "master", o, "", 1);
|
||||
check_generate(9, "site", "login", "master", o, "", 1);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -294,7 +314,7 @@ main(void)
|
||||
|
||||
memset(&o, 0, sizeof(o));
|
||||
o.length = 8;
|
||||
check_generate(7, "site", "login", "master", o, "", 1);
|
||||
check_generate(10, "site", "login", "master", o, "", 1);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -305,7 +325,7 @@ main(void)
|
||||
o.lowercase = 1;
|
||||
o.uppercase = 1;
|
||||
o.digits = 1;
|
||||
check_generate(8, "site", "login", "master", o, "", 1);
|
||||
check_generate(11, "site", "login", "master", o, "", 1);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -315,7 +335,14 @@ main(void)
|
||||
o.length = 8;
|
||||
o.digits = 1;
|
||||
o.exclude = "0123456789";
|
||||
check_generate(9, "site", "login", "master", o, "", 1);
|
||||
check_generate(12, "site", "login", "master", o, "", 1);
|
||||
}
|
||||
|
||||
{
|
||||
PassOptions o = defaults;
|
||||
|
||||
o.length = 4;
|
||||
check_generate(13, "site", "login", "master", o, "", 1);
|
||||
}
|
||||
|
||||
check_shape();
|
||||
|
||||
+36
-5
@@ -86,6 +86,16 @@ copy_text(char *dst, size_t dst_size, const char *src)
|
||||
dst[len] = '\0';
|
||||
}
|
||||
|
||||
static int
|
||||
clamp_length(int length)
|
||||
{
|
||||
if(length < PASS_MIN_LENGTH)
|
||||
return PASS_MIN_LENGTH;
|
||||
if(length > PASS_MAX_LENGTH)
|
||||
return PASS_MAX_LENGTH;
|
||||
return length;
|
||||
}
|
||||
|
||||
static void
|
||||
runtime_defaults(void)
|
||||
{
|
||||
@@ -100,9 +110,9 @@ runtime_defaults(void)
|
||||
runtime.settings.digits = 1;
|
||||
runtime.settings.symbols = 1;
|
||||
runtime.settings.exclude[0] = '\0';
|
||||
runtime.settings.theme_source = THEME_SOURCE_SYSTEM;
|
||||
runtime.settings.theme_source = THEME_SOURCE_APP;
|
||||
runtime.settings.theme_mode = THEME_MODE_SYSTEM;
|
||||
runtime.settings.theme_id = THEME_MINT;
|
||||
runtime.settings.theme_id = THEME_SWEET;
|
||||
runtime.settings.theme_style = THEME_STYLE_MATERIAL;
|
||||
copy_text(runtime.status, sizeof(runtime.status), "Ready");
|
||||
copy_text(runtime.fingerprint_status, sizeof(runtime.fingerprint_status), "No saved master password");
|
||||
@@ -145,7 +155,7 @@ load_settings(void)
|
||||
else if(strcmp(line, "show_fingerprint") == 0)
|
||||
runtime.settings.show_fingerprint = atoi(value) != 0;
|
||||
else if(strcmp(line, "length") == 0)
|
||||
runtime.settings.length = atoi(value);
|
||||
runtime.settings.length = clamp_length(atoi(value));
|
||||
else if(strcmp(line, "counter") == 0)
|
||||
runtime.settings.counter = atoi(value);
|
||||
else if(strcmp(line, "lower") == 0)
|
||||
@@ -170,6 +180,26 @@ load_settings(void)
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static void
|
||||
migrate_default_theme_settings(void)
|
||||
{
|
||||
int legacy_system_default =
|
||||
runtime.settings.theme_source == THEME_SOURCE_SYSTEM &&
|
||||
runtime.settings.theme_mode == THEME_MODE_SYSTEM &&
|
||||
(runtime.settings.theme_id == THEME_MINT ||
|
||||
runtime.settings.theme_id == THEME_SWEET) &&
|
||||
(runtime.settings.theme_style == THEME_STYLE_SYSTEM ||
|
||||
runtime.settings.theme_style == THEME_STYLE_MATERIAL);
|
||||
|
||||
if(!legacy_system_default)
|
||||
return;
|
||||
|
||||
runtime.settings.theme_source = THEME_SOURCE_APP;
|
||||
runtime.settings.theme_mode = THEME_MODE_SYSTEM;
|
||||
runtime.settings.theme_id = THEME_SWEET;
|
||||
runtime.settings.theme_style = THEME_STYLE_MATERIAL;
|
||||
}
|
||||
|
||||
static int
|
||||
write_settings(void)
|
||||
{
|
||||
@@ -240,7 +270,7 @@ load_profiles(void)
|
||||
!read_field(&cursor, p->login, sizeof(p->login)) ||
|
||||
!read_field(&cursor, scratch, sizeof(scratch)))
|
||||
continue;
|
||||
p->length = atoi(scratch);
|
||||
p->length = clamp_length(atoi(scratch));
|
||||
if(!read_field(&cursor, scratch, sizeof(scratch)))
|
||||
continue;
|
||||
p->counter = atoi(scratch);
|
||||
@@ -302,6 +332,7 @@ pass_runtime_init(void)
|
||||
{
|
||||
runtime_defaults();
|
||||
load_settings();
|
||||
migrate_default_theme_settings();
|
||||
load_profiles();
|
||||
}
|
||||
|
||||
@@ -532,7 +563,7 @@ pass_save_settings(int auto_copy, int clear_seconds, int show_fingerprint,
|
||||
runtime.settings.auto_copy = auto_copy != 0;
|
||||
runtime.settings.clear_seconds = clear_seconds < 0 ? 0 : clear_seconds;
|
||||
runtime.settings.show_fingerprint = show_fingerprint != 0;
|
||||
runtime.settings.length = length < 4 ? 4 : length;
|
||||
runtime.settings.length = clamp_length(length);
|
||||
runtime.settings.counter = counter < 1 ? 1 : counter;
|
||||
runtime.settings.lower = lower != 0;
|
||||
runtime.settings.upper = upper != 0;
|
||||
|
||||
@@ -11,5 +11,5 @@
|
||||
<launchable type="desktop-id">xyz.waozi.pass.desktop</launchable>
|
||||
<url type="homepage">https://github.com/waozixyz/pass</url>
|
||||
<provides><binary>pass-gui</binary></provides>
|
||||
<releases><release version="0.2.7" date="2026-08-24"/><release version="0.2.6" date="2026-08-24"/><release version="0.2.5" date="2026-08-24"/><release version="0.2.4" date="2026-08-22"/><release version="0.2.3" date="2026-08-21"/><release version="0.2.2" date="2026-08-20"/><release version="0.2.1" date="2026-08-19"/><release version="0.2.0" date="2026-08-18"/><release version="0.1.3" date="2026-08-17"/><release version="0.1.2" date="2026-08-17"/><release version="0.1.1" date="2026-08-17"/><release version="0.1.0" date="2026-08-17"/></releases>
|
||||
<releases><release version="0.2.8" date="2026-08-26"/><release version="0.2.7" date="2026-08-24"/><release version="0.2.6" date="2026-08-24"/><release version="0.2.5" date="2026-08-24"/><release version="0.2.4" date="2026-08-22"/><release version="0.2.3" date="2026-08-21"/><release version="0.2.2" date="2026-08-20"/><release version="0.2.1" date="2026-08-19"/><release version="0.2.0" date="2026-08-18"/><release version="0.1.3" date="2026-08-17"/><release version="0.1.2" date="2026-08-17"/><release version="0.1.1" date="2026-08-17"/><release version="0.1.0" date="2026-08-17"/></releases>
|
||||
</component>
|
||||
@@ -0,0 +1,139 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import hashlib
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
CHARACTER_SUBSETS = {
|
||||
"lowercase": "abcdefghijklmnopqrstuvwxyz",
|
||||
"uppercase": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
"digits": "0123456789",
|
||||
"symbols": "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
|
||||
}
|
||||
|
||||
|
||||
def consume_entropy(password, entropy, characters, max_length):
|
||||
while len(password) < max_length:
|
||||
entropy, remainder = divmod(entropy, len(characters))
|
||||
password += characters[remainder]
|
||||
return password, entropy
|
||||
|
||||
|
||||
def available_characters(rule, exclude):
|
||||
characters = "".join(c for c in CHARACTER_SUBSETS[rule] if c not in exclude)
|
||||
if not characters:
|
||||
raise ValueError(f"{rule} has no characters after exclusions")
|
||||
return characters
|
||||
|
||||
|
||||
def lesspass_password(profile, master):
|
||||
rules = [rule for rule in ("lowercase", "uppercase", "digits", "symbols")
|
||||
if profile[rule]]
|
||||
salt = profile["site"] + profile["login"] + format(profile["counter"], "x")
|
||||
entropy = int.from_bytes(
|
||||
hashlib.pbkdf2_hmac("sha256", master.encode("utf-8"),
|
||||
salt.encode("utf-8"), 100000, 32),
|
||||
"big",
|
||||
)
|
||||
alphabet = "".join(available_characters(rule, profile.get("exclude", ""))
|
||||
for rule in rules)
|
||||
password, entropy = consume_entropy("", entropy, alphabet,
|
||||
profile["length"] - len(rules))
|
||||
required = ""
|
||||
for rule in rules:
|
||||
value, entropy = consume_entropy(
|
||||
"", entropy, available_characters(rule, profile.get("exclude", "")), 1)
|
||||
required += value
|
||||
for char in required:
|
||||
entropy, position = divmod(entropy, len(password))
|
||||
password = password[:position] + char + password[position:]
|
||||
return password
|
||||
|
||||
|
||||
def pass_cli(cli, profile, master):
|
||||
cmd = [
|
||||
cli,
|
||||
"--length", str(profile["length"]),
|
||||
"--counter", str(profile["counter"]),
|
||||
]
|
||||
for rule in ("lowercase", "uppercase", "digits", "symbols"):
|
||||
if not profile[rule]:
|
||||
cmd.append(f"--no-{rule}")
|
||||
if profile.get("exclude"):
|
||||
cmd.extend(["--exclude", profile["exclude"]])
|
||||
cmd.extend([profile["site"], profile["login"], master])
|
||||
return subprocess.check_output(cmd, text=True).rstrip("\n")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--cli", default="./pass")
|
||||
args = parser.parse_args()
|
||||
|
||||
cases = [
|
||||
("reviewer default", {
|
||||
"site": "lesspass.com",
|
||||
"login": "[email protected]",
|
||||
"length": 16,
|
||||
"counter": 1,
|
||||
"lowercase": True,
|
||||
"uppercase": True,
|
||||
"digits": True,
|
||||
"symbols": True,
|
||||
}, "password"),
|
||||
("hex counter 10", {
|
||||
"site": "site",
|
||||
"login": "login",
|
||||
"length": 16,
|
||||
"counter": 10,
|
||||
"lowercase": True,
|
||||
"uppercase": True,
|
||||
"digits": True,
|
||||
"symbols": True,
|
||||
}, "test"),
|
||||
("hex counter 16", {
|
||||
"site": "site",
|
||||
"login": "login",
|
||||
"length": 16,
|
||||
"counter": 16,
|
||||
"lowercase": True,
|
||||
"uppercase": True,
|
||||
"digits": True,
|
||||
"symbols": True,
|
||||
}, "test"),
|
||||
("unicode and two classes", {
|
||||
"site": "δοκιμή.example",
|
||||
"login": "ユーザー",
|
||||
"length": 12,
|
||||
"counter": 7,
|
||||
"lowercase": True,
|
||||
"uppercase": False,
|
||||
"digits": True,
|
||||
"symbols": False,
|
||||
}, "pässword"),
|
||||
("excluded characters", {
|
||||
"site": "example.com",
|
||||
"login": "alice",
|
||||
"length": 24,
|
||||
"counter": 1,
|
||||
"lowercase": True,
|
||||
"uppercase": True,
|
||||
"digits": True,
|
||||
"symbols": True,
|
||||
"exclude": "0Ool1I!|",
|
||||
}, "correct horse battery staple"),
|
||||
]
|
||||
|
||||
for name, profile, master in cases:
|
||||
expected = lesspass_password(profile, master)
|
||||
actual = pass_cli(args.cli, profile, master)
|
||||
if actual != expected:
|
||||
print(f"FAIL {name}: got {actual!r}, want {expected!r}")
|
||||
return 1
|
||||
print(f"ok {name}: {actual}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
+13
-1
@@ -73,4 +73,16 @@ if [ -z "$changelog" ]; then
|
||||
echo "No changelog bullets found for $release_version in CHANGELOG.md" >&2
|
||||
exit 1
|
||||
fi
|
||||
printf '%s\n' "$changelog" | head -c 500 > "$changelog_dir/$release_code.txt"
|
||||
printf '%s\n' "$changelog" | awk '
|
||||
BEGIN { limit = 500; used = 0 }
|
||||
{
|
||||
line = $0 "\n"
|
||||
if (used + length(line) > limit)
|
||||
exit
|
||||
printf "%s", line
|
||||
used += length(line)
|
||||
}
|
||||
' > "$changelog_dir/$release_code.txt"
|
||||
if [ ! -s "$changelog_dir/$release_code.txt" ]; then
|
||||
printf '%s\n' "$changelog" | head -c 500 > "$changelog_dir/$release_code.txt"
|
||||
fi
|
||||
Vendored
+1
-1
Submodule vendor/kryon updated: 2f73accdb8...73ae09a559.
+1
-1
@@ -20,7 +20,7 @@
|
||||
<div class="preview" id="generator"><div class="preview-head"><i></i><i></i><i></i><span>generated locally</span></div><div class="preview-body"><div class="form-grid">
|
||||
<label>Site<input id="site" autocomplete="off" placeholder="example.org"></label><label>Login<input id="login" autocomplete="username" placeholder="[email protected]"></label>
|
||||
<label class="wide">Master password<span class="password-wrap"><input id="master" type="password" autocomplete="current-password"><button id="reveal" type="button" class="inline">Reveal</button></span></label>
|
||||
<label>Length<input id="length" type="number" min="1" max="128" value="16"></label><label>Counter<input id="counter" type="number" min="1" value="1"></label><label class="wide">Excluded characters<input id="exclude" autocomplete="off"></label>
|
||||
<label>Length<input id="length" type="number" min="5" max="35" value="16"></label><label>Counter<input id="counter" type="number" min="1" value="1"></label><label class="wide">Excluded characters<input id="exclude" autocomplete="off"></label>
|
||||
<fieldset class="wide"><legend>Character classes</legend><label><input id="lower" type="checkbox" checked> Lowercase</label><label><input id="upper" type="checkbox" checked> Uppercase</label><label><input id="digits" type="checkbox" checked> Digits</label><label><input id="symbols" type="checkbox" checked> Symbols</label></fieldset>
|
||||
<div class="wide actions"><button id="generate" class="button" disabled>Generate</button><button id="copy" class="button secondary" disabled>Copy</button><button id="clear" class="button ghost">Clear</button></div>
|
||||
<output id="result" class="wide" aria-live="polite">Your generated password appears here</output><p id="message" class="wide status"></p>
|
||||
|
||||
Reference in new issue
Block a user