diff options
| -rw-r--r-- | go.mod | 14 | ||||
| -rw-r--r-- | go.sum | 28 | ||||
| -rw-r--r-- | yubicrypt.go | 54 |
3 files changed, 42 insertions, 54 deletions
@@ -3,22 +3,22 @@ module yubicrypt go 1.25.0 require ( - fyne.io/fyne/v2 v2.6.3 + fyne.io/fyne/v2 v2.7.1 github.com/awnumar/memguard v0.23.0 github.com/go-piv/piv-go/v2 v2.4.0 ) require ( - fyne.io/systray v1.11.0 // indirect - github.com/BurntSushi/toml v1.4.0 // indirect + fyne.io/systray v1.11.1-0.20250603113521-ca66a66d8b58 // indirect + github.com/BurntSushi/toml v1.5.0 // indirect github.com/awnumar/memcall v0.4.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fredbi/uri v1.1.0 // indirect + github.com/fredbi/uri v1.1.1 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/fyne-io/gl-js v0.2.0 // indirect github.com/fyne-io/glfw-js v0.3.0 // indirect github.com/fyne-io/image v0.1.1 // indirect - github.com/fyne-io/oksvg v0.1.0 // indirect + github.com/fyne-io/oksvg v0.2.0 // indirect github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a // indirect github.com/go-text/render v0.2.0 // indirect @@ -32,10 +32,10 @@ require ( github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect github.com/nicksnyder/go-i18n/v2 v2.5.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rymdport/portal v0.4.1 // indirect + github.com/rymdport/portal v0.4.2 // indirect github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect - github.com/stretchr/testify v1.10.0 // indirect + github.com/stretchr/testify v1.11.1 // indirect github.com/yuin/goldmark v1.7.8 // indirect golang.org/x/crypto v0.41.0 // indirect golang.org/x/image v0.24.0 // indirect @@ -1,9 +1,9 @@ -fyne.io/fyne/v2 v2.6.3 h1:cvtM2KHeRuH+WhtHiA63z5wJVBkQ9+Ay0UMl9PxFHyA= -fyne.io/fyne/v2 v2.6.3/go.mod h1:NGSurpRElVoI1G3h+ab2df3O5KLGh1CGbsMMcX0bPIs= -fyne.io/systray v1.11.0 h1:D9HISlxSkx+jHSniMBR6fCFOUjk1x/OOOJLa9lJYAKg= -fyne.io/systray v1.11.0/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs= -github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= -github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +fyne.io/fyne/v2 v2.7.1 h1:ja7rNHWWEooha4XBIZNnPP8tVFwmTfwMJdpZmLxm2Zc= +fyne.io/fyne/v2 v2.7.1/go.mod h1:xClVlrhxl7D+LT+BWYmcrW4Nf+dJTvkhnPgji7spAwE= +fyne.io/systray v1.11.1-0.20250603113521-ca66a66d8b58 h1:eA5/u2XRd8OUkoMqEv3IBlFYSruNlXD8bRHDiqm0VNI= +fyne.io/systray v1.11.1-0.20250603113521-ca66a66d8b58/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs= +github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= +github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/awnumar/memcall v0.4.0 h1:B7hgZYdfH6Ot1Goaz8jGne/7i8xD4taZie/PNSFZ29g= github.com/awnumar/memcall v0.4.0/go.mod h1:8xOx1YbfyuCg3Fy6TO8DK0kZUua3V42/goA5Ru47E8w= github.com/awnumar/memguard v0.23.0 h1:sJ3a1/SWlcuKIQ7MV+R9p0Pvo9CWsMbGZvcZQtmc68A= @@ -13,8 +13,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g= github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw= -github.com/fredbi/uri v1.1.0 h1:OqLpTXtyRg9ABReqvDGdJPqZUxs8cyBDOMXBbskCaB8= -github.com/fredbi/uri v1.1.0/go.mod h1:aYTUoAXBOq7BLfVJ8GnKmfcuURosB1xyHDIfWeC/iW4= +github.com/fredbi/uri v1.1.1 h1:xZHJC08GZNIUhbP5ImTHnt5Ya0T8FI2VAwI/37kh2Ko= +github.com/fredbi/uri v1.1.1/go.mod h1:4+DZQ5zBjEwQCDmXW5JdIjz0PUA+yJbvtBv+u+adr5o= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/fyne-io/gl-js v0.2.0 h1:+EXMLVEa18EfkXBVKhifYB6OGs3HwKO3lUElA0LlAjs= @@ -23,8 +23,8 @@ github.com/fyne-io/glfw-js v0.3.0 h1:d8k2+Y7l+zy2pc7wlGRyPfTgZoqDf3AI4G+2zOWhWUk github.com/fyne-io/glfw-js v0.3.0/go.mod h1:Ri6te7rdZtBgBpxLW19uBpp3Dl6K9K/bRaYdJ22G8Jk= github.com/fyne-io/image v0.1.1 h1:WH0z4H7qfvNUw5l4p3bC1q70sa5+YWVt6HCj7y4VNyA= github.com/fyne-io/image v0.1.1/go.mod h1:xrfYBh6yspc+KjkgdZU/ifUC9sPA5Iv7WYUBzQKK7JM= -github.com/fyne-io/oksvg v0.1.0 h1:7EUKk3HV3Y2E+qypp3nWqMXD7mum0hCw2KEGhI1fnBw= -github.com/fyne-io/oksvg v0.1.0/go.mod h1:dJ9oEkPiWhnTFNCmRgEze+YNprJF7YRbpjgpWS4kzoI= +github.com/fyne-io/oksvg v0.2.0 h1:mxcGU2dx6nwjJsSA9PCYZDuoAcsZ/OuJlvg/Q9Njfo8= +github.com/fyne-io/oksvg v0.2.0/go.mod h1:dJ9oEkPiWhnTFNCmRgEze+YNprJF7YRbpjgpWS4kzoI= github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 h1:5BVwOaUSBTlVZowGO6VZGw2H/zl9nrd3eCZfYV+NfQA= github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a h1:vxnBhFDDT+xzxf1jTJKMKZw3H0swfWk9RpWbBbDK5+0= @@ -61,14 +61,14 @@ github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA= github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rymdport/portal v0.4.1 h1:2dnZhjf5uEaeDjeF/yBIeeRo6pNI2QAKm7kq1w/kbnA= -github.com/rymdport/portal v0.4.1/go.mod h1:kFF4jslnJ8pD5uCi17brj/ODlfIidOxlgUDTO5ncnC4= +github.com/rymdport/portal v0.4.2 h1:7jKRSemwlTyVHHrTGgQg7gmNPJs88xkbKcIL3NlcmSU= +github.com/rymdport/portal v0.4.2/go.mod h1:kFF4jslnJ8pD5uCi17brj/ODlfIidOxlgUDTO5ncnC4= github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c h1:km8GpoQut05eY3GiYWEedbTT0qnSxrCjsVbb7yKY1KE= github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c/go.mod h1:cNQ3dwVJtS5Hmnjxy6AgTPd0Inb3pW05ftPSX7NZO7Q= github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef h1:Ch6Q+AZUxDBCVqdkI8FSpFyZDtCVBc2VmejdNrm5rRQ= github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic= github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= diff --git a/yubicrypt.go b/yubicrypt.go index 65a634d..720b74b 100644 --- a/yubicrypt.go +++ b/yubicrypt.go @@ -1258,29 +1258,22 @@ func (identicon *ClassicIdenticon) getByte(n int) byte { return identicon.source[n%len(identicon.source)]
}
-// foreground computes primary color
+// foreground computes primary color using indexed palette (same as identicons program)
func (identicon *ClassicIdenticon) foreground() color.Color {
if len(identicon.source) < 32 {
return color.RGBA{0, 0, 0, 255}
}
- // Use bit 255 to decide: 0 → original HSL, 1 → palette
- if !identicon.getBit(255) {
- // Original HSL algorithm — soft and harmonious
- h1 := (uint16(identicon.getByte(28)) & 0x0f) << 8
- h2 := uint16(identicon.getByte(29))
- h := uint32(h1 | h2)
- s := uint32(identicon.getByte(30))
- l := uint32(identicon.getByte(31))
-
- hue := mapValue(h, 0, 4095, 0, 360)
- sat := mapValue(s, 0, 255, 0, 20)
- lum := mapValue(l, 0, 255, 0, 20)
-
- return identicon.hslToRgb(hue, 65.0-sat, 75.0-lum)
+ // Primary color index (4 bits → 16 colors) - EXACTLY like identicons program
+ colorIndex := 0
+ for i := 0; i < 4; i++ {
+ if identicon.getBit(248 + i) {
+ colorIndex |= 1 << i
+ }
}
+ colorIndex %= 16
- // Vibrant color palette — 16 beautiful, distinct colors
+ // Vibrant color palette — 16 beautiful, distinct colors (SAME as identicons program)
palette := []color.RGBA{
{0x00, 0xbf, 0x93, 0xff}, // turquoise
{0x2d, 0xcc, 0x70, 0xff}, // mint
@@ -1300,30 +1293,25 @@ func (identicon *ClassicIdenticon) foreground() color.Color { {0x1c, 0xab, 0xbb, 0xff}, // lightBlueIntense
}
- // Use bits 248-251 to select color (4 bits → 16 colors)
- colorIndex := 0
- for i := 0; i < 4; i++ {
- if identicon.getBit(248 + i) {
- colorIndex |= 1 << i
- }
- }
- return palette[colorIndex%len(palette)]
+ return palette[colorIndex]
}
-// secondaryColor computes second color (for 2-color mode)
+// secondaryColor computes second color using indexed palette (same as identicons program)
func (identicon *ClassicIdenticon) secondaryColor() color.Color {
if len(identicon.source) < 32 {
return color.RGBA{100, 100, 100, 255}
}
- // Use different bits: 244-247 for second color
+ // Secondary color index (4 bits → 16 colors) - EXACTLY like identicons program
colorIndex := 0
for i := 0; i < 4; i++ {
if identicon.getBit(244 + i) {
colorIndex |= 1 << i
}
}
+ colorIndex %= 16
+ // Secondary color palette — 16 distinct colors (SAME as identicons program)
palette := []color.RGBA{
{0x34, 0x49, 0x5e, 0xff}, // darkBlue
{0x95, 0xa5, 0xa5, 0xff}, // grey
@@ -1343,7 +1331,7 @@ func (identicon *ClassicIdenticon) secondaryColor() color.Color { {0x7e, 0x8c, 0x8d, 0xff}, // greyIntense
}
- return palette[colorIndex%len(palette)]
+ return palette[colorIndex]
}
// hslToRgb converts HSL to RGB in original style
@@ -1472,9 +1460,9 @@ func (identicon *ClassicIdenticon) Generate() image.Image { secondaryColor := identicon.secondaryColor()
img := image.NewRGBA(image.Rect(0, 0, identicon.size, identicon.size))
- // Background adapts to theme — use bits 252-254 to pick variation
+ // Background adapts to theme — use bits 252-253 to pick variation (2 bits → 3 options)
bgChoice := 0
- for i := 0; i < 3; i++ {
+ for i := 0; i < 2; i++ { // Nur 2 Bits verwenden wie in identicons program
if identicon.getBit(252 + i) {
bgChoice |= 1 << i
}
@@ -1488,8 +1476,8 @@ func (identicon *ClassicIdenticon) Generate() image.Image { }
darkBackgrounds := []color.RGBA{
{30, 30, 30, 255}, // dark gray
- {45, 62, 80, 255}, // darkBlueIntense
- {57, 57, 57, 255}, // dark2
+ {45, 62, 80, 255}, // darkBlueIntense
+ {57, 57, 57, 255}, // dark2
}
var bg color.RGBA
@@ -1550,9 +1538,9 @@ func (identicon *ClassicIdenticon) GenerateForExport(transparent bool) image.Ima if transparent {
bg = color.RGBA{0, 0, 0, 0} // fully transparent
} else {
- // Use bits 252-254 for background choice
+ // Use bits 252-253 for background choice (2 bits → 3 options)
bgChoice := 0
- for i := 0; i < 3; i++ {
+ for i := 0; i < 2; i++ {
if identicon.getBit(252 + i) {
bgChoice |= 1 << i
}
|
