HNHacker News
TopNewBestAskShowJobs

evgpbfhnr

435 karma · joined July 4, 2022

submissionscomments
evgpbfhnr··on Preventing IoT Edge Device Cloning
"How it works" https://realtimelogic.com/ba/doc/en/SoftTPM.html

I couldn't find "actual sources", but one of their github repo has this: https://github.com/RealTimeLogic/BAS/blob/main/examples/Mako...

Which extracts to this .config file (looks like lua code, that creates a secret from PBKDF2 of... what? I couldn't find where secrets would come from here, but that repo obviously misses the interesting bindings; from the how it works link it looks like they're just hashing the SN to generate a pseudorandom key but I don't see why you couldn't just generate a key for neighboring devices by just faking the SN then...)

    local maxHash=pcall(function() ba.crypto.hash("sha512") end) and "sha512" or "sha256"
    local sfmt,jencode,jdecode,symmetric,PBKDF2,keyparams,sign,jwtsign,createkey,createcsr,sharkcert=
    string.format,ba.json.encode,ba.json.decode,ba.crypto.symmetric,ba.crypto.PBKDF2,ba.crypto.keyparams,
    ba.crypto.sign,require"jwt".sign,ba.create.key,ba.create.csr,ba.create.sharkcert
    local function setuser(ju,db,name,pwd)
    if pwd then
    if type(pwd) == "string" then
    pwd={pwd=pwd,roles={}}
    end
    db[name]=pwd
    else
    db[name]=nil
    end
    local ok,err=ju:set(db)
    if not ok then error(err,3) end
    end
    local function tpm(gpkey,upkey)
    local keys={}
    local function tpmGetKey(kname)
    local key=keys[kname]
    if not key then error(sfmt("ECC key %s not found",tostring(kname)),3) end
    return key
    end
    local function tpmSign(h,kname,op) return sign(h,tpmGetKey(kname),op) end
    local function tpmJwtsign(p,kname,op) return jwtsign(p,function(h) return sign(h,tpmGetKey(kname)) end,op) end
    local function tpmKeyparams(kname) return keyparams(tpmGetKey(kname)) end
    local function tpmCreatecsr(kname,...) return createcsr(tpmGetKey(kname),...) end
    local function tpmCreatekey(kname,op)
    if keys[kname] then error(sfmt("ECC key %s exists",kname),2) end
    op = op or {}
    if op.key and op.key ~= "ecc" then error("TPM can only create ECC keys",2) end
    local newOp={}
    for k,v in pairs(op) do newOp[k]=v end
    newOp.rnd=PBKDF2(maxHash,"@#"..kname,upkey,5,1024)
    local key=createkey(newOp)
    keys[kname]=key
    return true
    end
    local function tpmHaskey(kname) return keys[kname] and true or false end
    local function tpmSharkcert(kname,certdata) return sharkcert(certdata,tpmGetKey(kname)) end
    require"acme/engine".setTPM{jwtsign=tpmJwtsign,keyparams=tpmKeyparams,createcsr=tpmCreatecsr,createkey=tpmCreatekey,haskey=tpmHaskey}
    local t={}
    function t.haskey(k) return tpmHaskey(k) end
    function t.createkey(k,...) return tpmCreatekey(k,...) end
    function t.createcsr(k,...) return tpmCreatecsr(k,...) end
    function t.sign(h,k,o) return tpmSign(h,k,o) end
    function t.jwtsign(k,...) return tpmJwtsign(k,...) end
    function t.keyparams(k,...) return tpmKeyparams(k,...) end
    function t.sharkcert(k,...) return tpmSharkcert(k,...) end
    function t.globalkey(n,l) return PBKDF2(maxHash,n,gpkey,5,l) end
    function t.uniquekey(n,l) return PBKDF2(maxHash,n,upkey,5,l) end
    function t.jsonuser(k,global)
    k=PBKDF2("sha256","@#"..k,global and gpkey or upkey,6,1)
    local function enc(db)
    local iv=ba.rndbs(12)
    local gcmEnc=symmetric("GCM",k,iv)
    local cipher,tag=gcmEnc:encrypt(jencode(db),"PKCS7")
    return iv..tag..cipher
    end
    local function dec(encdb)
    if encdb and #encdb > 30 then
    local iv=encdb:sub(1,12)
    local tag=encdb:sub(13,28)
    local gcmDec=symmetric("GCM",k,iv)
    local db
    pcall(function() db=jdecode(gcmDec:decrypt(encdb:sub(29,-1),tag,"PKCS7")) end)
    if db then return db end
    end
    return nil,"Data corrupt"
    end
    local ju,db=ba.create.jsonuser(),{}
    return {
    users=function() local x={} for u in pairs(db) do table.insert(x,u) end return x end,
    setuser=function(name,pwd) setuser(ju,db,name,pwd) return enc(db) end,
    setdb=function(encdb) local d,err,ok=dec(encdb) if d then ok,err=ju:set(d) if ok then db=d return ok end end return nil,err end,
    getauth=function() return ju end
    }
    end
    ba.tpm=t
    end
    
    local klist={}
    return function(x)
    if true == x then
    local hf=ba.crypto.hash(maxHash)
    for _,k in ipairs(klist) do hf(k) end
    tpm(ba.crypto.hash(maxHash)(klist[1])(true),hf(true))
    klist=nil
    return
    end
    table.insert(klist,x)
    end
evgpbfhnr··on GrapheneOS accessed Android security patches but not allowed to publish sources
They have access to the patches.

They just can't make an official release with it, because they can't publish the patch sources (embargoed) and their releases being open-source must match what they published...

evgpbfhnr··on I don't want AI agents controlling my laptop
bwrap.

I don't run AI, but anything I don't fully trust 200% runs without access to my home, and if it doesn't really need internet without internet either. bwrap commands can be a mouthful so I suggest making a script for things you commonly do, e.g. "run with this directory as $HOME" or "run with empty home, keeping just this directory as is", with a couple of flags to enable networking or wayland/sound... Once you have this there really is no benefit to not sandboxing. It's probably not as good as running in a full VM, but it's good enough for me.

evgpbfhnr··on Bouncing on trampolines to run eBPF programs
Hm, I'm not sure it makes sense to add more arguments before the feature works.. But I think I was just not up to date.

Looking around the patches they sent, they've also gotten rid of tools/testing/selftests/bpf/DENYLIST.aarch64 so now all bpf features should be working on aarch64 including fentry/fexit (removed in 149ead9d7e3d selftests/bpf: enable many-args tests for arm64)

I think I'm just out of the loop and fentry can work since 6.14 on arm64 with this merge commit "Have fprobes built on top of function graph infrastructure" https://git.kernel.org/linus/2e04247f7cce8b8cd8381a290787016...

Shame we're just getting started porting our board to 6.12 so I won't see this for another few years, but I'll give mainline a new spin sooner or later...

evgpbfhnr··on Bouncing on trampolines to run eBPF programs
One thing I don't get is that arm64 doesn't have fentry support.. does it? At least I just checked CONFIG_HAVE_FENTRY is not set on arm64, and e.g. (not checked recently) bpftrace --info used to print `fentry: no`, so how does this trampoline talk on arm64 apply without this part?
evgpbfhnr··on Show HN: Kitten TTS – 25MB CPU-Only, Open-Source TTS Model
I tried on some Japanese for the kicks of it, it reads... "Chinese letter chinese letter japanese letter chinese letter..." :D

But yeah, if it's like any of the others we'll likely see a different "model" per language down the line based on the same techniques

evgpbfhnr··on Trying Guix: A Nixer's impressions
I've switched from wmii (old suckless tiling wm) to niri a couple of months ago and I've been happier with it than with sway/i3 -- give it a shot :)
evgpbfhnr··on Faking a JPEG
when crawlers use a botnet to only make one request per ip per long duration that's not realistic to implement though..
evgpbfhnr··on Some __nonstring__ Turbulence
He releases rc every single week (ok, except before rc1 there's two weeks for merge window), there's no "off" time to upgrade anywhere.

Not that I approve the untested changes, I'd have used a different gcc temporarily (container or whatever), but, yeah, well...

evgpbfhnr··on The Web Is Broken – Botnet Part 2
or just that they don't run windows/mac OS with chome like everyone else and it's "suspicious". I get cloudflare capchas all the time with firefox on linux... (and I'm pretty sure there's no such app in my home network!)
evgpbfhnr··on Better Shell History Search
I've considered this, but I'm running on a potato, and fetching the whole atuin history seems to take a while:

    $ time atuin history list --print0 -f "{time} | {command}" > /dev/null
    
    real 0m1.849s
(for some reason the built-in atuin search command doesn't take so long to show up? It might only fetch the last few entries from the db first... Eh, actually `atuin search` without argument which lists roughly the same thing run in less than half the time (0.85s), but -i is still another order of magnitude faster)

Anyway, thanks - I'll fiddle with all this :)

evgpbfhnr··on The Future Is Niri
I couldn't find a run or raise repo that'd have a ws.jq and I'm not convinced it's https://github.com/thaliaarchi/wsjq (whitespace programing language implemented in jq...) Could you point at that?

Thanks for sharing!

evgpbfhnr··on A bookmarklet to kill sticky headers (2013)
Thank you (and neighbors), I didn't know this.
evgpbfhnr··on A bookmarklet to kill sticky headers (2013)
Interestingly running this in the console works but from a bookmarklet changes all the page content to false,false,false,.... (on firefox)

Any idea?

evgpbfhnr··on A bookmarklet to kill sticky headers (2013)
If someone has one for the "share this" popups when you select some text in way too many articles/blogs I'd love to add this to my collection...
evgpbfhnr··on Today I learned that bash has hashmaps (2024)
Don't loop on values with `*`; the difference key/value is the lack of `!` at the start of the expression; `*` and `@` rules are the sames a $@ and $* and you almost never want *.
evgpbfhnr··on Jujutsu Megamerges and jj Absorb
Thanks! My nixpkgs clone is 5.2GB so it's not too far indeed! :)

I think the nixpkgs workflow is much less prone to rebase/merges (some cherry-picks to stable branches I don't do much), but it's a very good data point, thank you. I guess I'll give it a try over christmas break..

evgpbfhnr··on Jujutsu Megamerges and jj Absorb
> Though at this point I don’t even bother colocating the .git repo alongside .jj. Meaning I haven’t found a need to fall back to git commands in maybe four or five months.

That interests me -- is there a native jj protocol for push/fetch? Even if just ssh? Or do you just work in local repos?

evgpbfhnr··on Jujutsu Megamerges and jj Absorb
How does jj handle very large git repos, e.g. this linux clone with a mix&mash of quite a few upstreams with a 6GB big .git dir?

(I agree I probably shouldn't focus on that first, and could just try jj first on smaller rpos... But git is already slow enough in there that it's an honest question, I don't need to keep using git there as long as I can keep pulling from stable kernels git trees for regular merges)

evgpbfhnr··on Only buy a magnetic keyboard for gaming
Interesting, their configuration tool runs in browser and they explicitly mention linux; I don't have much experience with gaming keyboards but the only one I bought in the past had some windows-only configuration software and was a bit of a pain.
evgpbfhnr··on Show HN: Retry a command with exponential backoff and jitter (+ Starlark exprs)
Looks similar to https://github.com/rye/eb
evgpbfhnr··on NixOS is a good server OS, except when it isn't
mounting /nix/store from the host into the guest works with as many guests as you like - this is what the nixos tests framework does all the time, you just need a different "system" derivation for each (different) VM.

The problem with that is that the VM can see all the needless software, so if your goal is isolation, having a smaller closure is much better from a security point of view: if there's no coreutils bash etc then there's no risk of getting a shell spawned by an attack...

evgpbfhnr··on NixOS is a good server OS, except when it isn't
Couple of things spring to mind:

- didn't check if nixos uses it, but coreutil has a single binary mode (like busybox, a single binary is built and symlinks or hardlinks are used to provide all the commands); that might save some space

- instead of trying to strip down the system, maybe go the other way around: only include the command you need with its closure? closure computation is done in a few places (apparmor profile or systemd.confinement come to mind) and it should be possible to just copy whatever your server binary needs, your kernel (since microVM and not container), and run the binary directly as init (maybe with a simple wrapper that hardcodes network or whatsnot)

good luck!

evgpbfhnr··on MNT Reform Next
https://shop.mntre.com/products/mnt-reform-rcore-rk3588-proc... 500/750€ for the som is a bit spicy considering the soc itself can be brought for $150 in orange pi 5 plus (16GB); being part of the business I know how big the economy of scale is, but it still is off putting as a consumer.

Hopefully selling it as part of the new laptop will allow sufficiently bigger batches to bring this down a bit

evgpbfhnr··on Show HN: bpfquery – experimenting with compiling SQL to bpf(trace)
Try this:

    bpftrace -lv kfunc:*
(or any specific function instead of wildcard) will get you all kfuncs and their respective arguments.

output snippet:

    kfunc:vmlinux:tcp_conn_request
        struct request_sock_ops * rsk_ops
        const struct tcp_request_sock_ops * af_ops
        struct sock * sk
        struct sk_buff * skb
        int retval
    kfunc:vmlinux:tcp_connect
        struct sock * sk
        int retval
    kfunc:vmlinux:tcp_create_openreq_child
        const struct sock * sk
        struct request_sock * req
        struct sk_buff * skb
        struct sock * retval
I'm not sure how to get this info without bpftrace itself - bpftool might have the info available somehow?
evgpbfhnr··on Alacrity to Federated Cryptography
I'm curious how that's supposed to work with stable distros like debian, ship protocol upgrades as security fixes or at least each point release (+LTS?)

If it's in rust or anything that requires new compilers to build that doesn't sound easy, debian stable ought to be able to communicate with current software but the stable that uses rust 1.63 (2022-08, 1 year old as of first bookworm stable release) and supported (without any LTS) until 2026-06, at which point rust will be 4 years old and it'll be almost impossible to build anything with it, which is required for official packages that can't depend on rustup or similar... LTS being even more out of question.

Well, I guess it can't hurt to try.

evgpbfhnr··on Ircpipe – Netcat for IRC
see also: https://tools.suckless.org/ii/
evgpbfhnr··on Facebook Helped the FBI Exploit Vulnerability in a Secure Linux Distro (2020)
Please add a "(2020)" to the title, only noticed after reading this and looking for details about the actual vuln to check if I had something to update...
evgpbfhnr··on Using ARG in a Dockerfile – beware the gotcha
`set -e` is evil: https://web.archive.org/web/20240511180116/https://mywiki.wo... (wooledge wiki doesn't seem to load for me for some reason so archive.org it is)
evgpbfhnr··on Securing Git Repositories with Gittuf
People trust the forge all the time; if someone wants to mess with github (say, feed a different repo for everyone except developers using whatever it is they usually interact with the git with (ssh or their IP or whatever), it'd take a while to notice -- if they do that for existing releases archives distros might notice but for a new tag? I'll bet no-one sees it)

From a pure git perspective, notes are normal objects so if everyone fetches the notes regularly they'll notice if they're tempered with just like regular commits iirc. I think you can add notes after the fact but not modify what's there?

← PreviousPage 2 of 4Next →