{"id":51043743,"url":"https://github.com/floatpane/go-openpgp-card-hl","last_synced_at":"2026-06-22T12:02:24.850Z","repository":{"id":361568906,"uuid":"1254951656","full_name":"floatpane/go-openpgp-card-hl","owner":"floatpane","description":"High-level YubiKey OpenPGP signer/decryptor","archived":false,"fork":false,"pushed_at":"2026-06-18T14:17:40.000Z","size":147,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-18T14:29:05.580Z","etag":null,"topics":["code-signing","cryptography","digital-signature","ed25519","encryption","git-signing","gnupg","go","go-library","golang","gpg","hardware-token","nitrokey","openpgp","openpgp-card","pcsc","pgp","rsa","smartcard","yubikey"],"latest_commit_sha":null,"homepage":"https://cardhl.floatpane.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/floatpane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"floatpane"}},"created_at":"2026-05-31T07:49:13.000Z","updated_at":"2026-06-18T14:18:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/floatpane/go-openpgp-card-hl","commit_stats":null,"previous_names":["floatpane/go-openpgp-card-hl"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/floatpane/go-openpgp-card-hl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fgo-openpgp-card-hl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fgo-openpgp-card-hl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fgo-openpgp-card-hl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fgo-openpgp-card-hl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floatpane","download_url":"https://codeload.github.com/floatpane/go-openpgp-card-hl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatpane%2Fgo-openpgp-card-hl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34647750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-signing","cryptography","digital-signature","ed25519","encryption","git-signing","gnupg","go","go-library","golang","gpg","hardware-token","nitrokey","openpgp","openpgp-card","pcsc","pgp","rsa","smartcard","yubikey"],"created_at":"2026-06-22T12:02:23.864Z","updated_at":"2026-06-22T12:02:24.836Z","avatar_url":"https://github.com/floatpane.png","language":"Go","funding_links":["https://github.com/sponsors/floatpane"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# go-openpgp-card-hl\n\n**High-level OpenPGP smartcard signer \u0026 decryptor for Go — YubiKey, Nitrokey, and friends.**\n\n[![Go Version](https://img.shields.io/github/go-mod/go-version/floatpane/go-openpgp-card-hl)](https://golang.org)\n[![Go Reference](https://pkg.go.dev/badge/github.com/floatpane/go-openpgp-card-hl.svg)](https://pkg.go.dev/github.com/floatpane/go-openpgp-card-hl)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/floatpane/go-openpgp-card-hl)](https://github.com/floatpane/go-openpgp-card-hl/releases)\n[![CI](https://github.com/floatpane/go-openpgp-card-hl/actions/workflows/ci.yml/badge.svg)](https://github.com/floatpane/go-openpgp-card-hl/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n\u003c/div\u003e\n\n`go-openpgp-card-hl` is the friendly front door to an OpenPGP smartcard. It\nwraps the low-level transport ([`cunicu.li/go-iso7816`](https://github.com/cunicu/go-iso7816)\n+ [`cunicu.li/go-openpgp-card`](https://github.com/cunicu/go-openpgp-card)) and\nthe OpenPGP packet layer ([`ProtonMail/go-crypto`](https://github.com/ProtonMail/go-crypto))\nbehind three operations — **sign**, **decrypt**, **list-keys** — with errors\nthat tell a human what to do next instead of leaking raw APDU status words.\n\nThe private key never leaves the card. Signing and decryption run on the device.\n\n## Features\n\n- **Detached, armored signatures.** `Sign` produces a standard\n  `-----BEGIN PGP SIGNATURE-----` block over arbitrary bytes — exactly what git\n  commit signing, `multipart/signed` mail, and age-plugin-style tooling need.\n- **EdDSA, RSA, and ECDSA signing.** The signature packet is built to the right\n  MPI shape per algorithm; the card just signs the digest.\n- **RSA decryption.** `Decrypt` unwraps the session key on the card via\n  `crypto.Decrypter` and hands the symmetric layer to `go-crypto`.\n- **Structured card info.** `Info` / `ListKeys` give you manufacturer, serial,\n  cardholder, and each slot's algorithm, status, and fingerprint.\n- **Actionable errors.** `ErrNoPCSC`, `ErrNoCard`, `ErrPIN`, `ErrUnsupportedKey`\n  — matchable with `errors.Is`, each wrapping a message a user can act on.\n\n## Install\n\n```bash\ngo get github.com/floatpane/go-openpgp-card-hl\n```\n\nRequires Go 1.26+, a PC/SC stack (`pcscd` on Linux), and an OpenPGP smartcard.\n\n## Usage\n\n### Sign\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"os\"\n\n    cardhl \"github.com/floatpane/go-openpgp-card-hl\"\n)\n\nfunc main() {\n    card, err := cardhl.Open()\n    if err != nil {\n        log.Fatal(err) // e.g. \"no OpenPGP smartcard found: … plug in your YubiKey\"\n    }\n    defer card.Close()\n\n    // The signing key's public half supplies the signature-packet metadata.\n    pub, err := cardhl.LoadPublicKey(\"key.asc\")\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    sig, err := card.Sign([]byte(\"hello, world\"), os.Getenv(\"PIN\"), pub)\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Println(string(sig)) // -----BEGIN PGP SIGNATURE-----\n}\n```\n\n### List keys\n\n```go\ninfo, err := card.Info()\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Print(info) // Manufacturer / Serial / Version / Cardholder / per-slot keys\n```\n\n### Decrypt (RSA)\n\n```go\nkey, err := cardhl.LoadEntity(\"recipient.asc\") // public key with an encryption subkey\nif err != nil {\n    log.Fatal(err)\n}\nplain, err := card.Decrypt(ciphertext, os.Getenv(\"PIN\"), key)\nif err != nil {\n    log.Fatal(err)\n}\n```\n\n\u003e ECDH / Curve25519 decryption keys are not supported — the unwrap needs scalar\n\u003e access the card does not expose. Use `gpg-agent` for those. RSA works because\n\u003e `go-crypto` accepts a `crypto.Decrypter`.\n\n## How signing works\n\n`Sign` builds a v4 OpenPGP signature packet by hand: it assembles the hashed\nsubpackets (creation time, issuer key ID, issuer fingerprint), computes the\nRFC 4880 hash over `data || hash-suffix || trailer`, and asks the card to sign\nthe digest. The raw signature is encoded into the right MPI form for the key's\nalgorithm (two MPIs for EdDSA/ECDSA, one for RSA) and wrapped in ASCII armor.\n\nThe signature covers `data` verbatim as a *binary document* (type `0x00`).\nHigher-level framing — the MIME `multipart/signed` envelope, the git signature\nformat — is the caller's job; hash the bytes you want covered and pass them in.\n\n## Documentation\n\nFull API reference: [pkg.go.dev/github.com/floatpane/go-openpgp-card-hl](https://pkg.go.dev/github.com/floatpane/go-openpgp-card-hl)\n\n## Contributing\n\nPRs welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Security\n\nThe private key stays on the card. Report vulnerabilities privately via\n[SECURITY.md](SECURITY.md).\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatpane%2Fgo-openpgp-card-hl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloatpane%2Fgo-openpgp-card-hl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatpane%2Fgo-openpgp-card-hl/lists"}