{"id":46456109,"url":"https://github.com/wenceslas-sanchez/proton-drive","last_synced_at":"2026-03-06T01:54:02.319Z","repository":{"id":340032322,"uuid":"1122473791","full_name":"wenceslas-sanchez/proton-drive","owner":"wenceslas-sanchez","description":"Async Proton Drive client with end-to-end encryption, SRP authentication and OpenPGP key management","archived":false,"fork":false,"pushed_at":"2026-03-04T20:24:37.000Z","size":421,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-05T02:18:53.845Z","etag":null,"topics":["async","cloud-storage","e2ee","end-to-end-encryption","openpgp","pgp","privacy","proton-drive","proton-mail","protonmail","python","self-hosted","srp"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wenceslas-sanchez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"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}},"created_at":"2025-12-24T20:09:32.000Z","updated_at":"2026-03-04T20:24:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/wenceslas-sanchez/proton-drive","commit_stats":null,"previous_names":["wenceslas-sanchez/proton-drive"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wenceslas-sanchez/proton-drive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenceslas-sanchez%2Fproton-drive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenceslas-sanchez%2Fproton-drive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenceslas-sanchez%2Fproton-drive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenceslas-sanchez%2Fproton-drive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wenceslas-sanchez","download_url":"https://codeload.github.com/wenceslas-sanchez/proton-drive/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenceslas-sanchez%2Fproton-drive/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30158253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"ssl_error","status_checked_at":"2026-03-05T22:39:24.771Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["async","cloud-storage","e2ee","end-to-end-encryption","openpgp","pgp","privacy","proton-drive","proton-mail","protonmail","python","self-hosted","srp"],"created_at":"2026-03-06T01:54:01.357Z","updated_at":"2026-03-06T01:54:02.294Z","avatar_url":"https://github.com/wenceslas-sanchez.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# proton-drive-client\n\nA Python async client to access your Proton Drive programmatically, browse the tree, download files, and decrypt them on the fly.\n\n## Install\n\n```bash\ngit clone https://github.com/wenceslas-sanchez/proton-drive.git\ncd proton-drive\nuv sync\n```\n\n## Quick start\n\n```python\nimport asyncio\nfrom proton_drive import ProtonDriveClient\n\nasync def main():\n    async with ProtonDriveClient() as client:\n        await client.authenticate(\"user@proton.me\", \"password\")\n\n        if client.requires_2fa:\n            await client.provide_2fa(input(\"2FA code: \"))\n\n        # Browse\n        root = await client.build_tree()\n        print(root)\n\n        # List a directory\n        nodes = await client.list_directory(\"/Documents\")\n\n        # Download a file\n        async for chunk in client.download_file(\"/Documents/report.pdf\"):\n            ...\n\n        # Download to disk\n        await client.download_to_file(\"/Documents/report.pdf\", \"./report.pdf\")\n\nasyncio.run(main())\n```\n\n## API\n\n### `ProtonDriveClient`\n\n| Method | Description |\n|---|---|\n| `authenticate(username, password)` | Log in |\n| `provide_2fa(code)` | Submit TOTP/2FA code |\n| `logout()` | Log out |\n| `build_tree(max_depth=50)` | Build the full folder tree |\n| `list_directory(path=\"/\")` | List direct children of a folder |\n| `get_node(path)` | Get a node by path, or `None` |\n| `download_file(path)` | Async generator yielding decrypted bytes |\n| `download_to_file(path, destination)` | Download and write to disk |\n\n## How encryption works\n\nProton Drive is end-to-end encrypted. Everything revolves around a **key hierarchy** and **per-file session keys**.\n\n### Key hierarchy\n\n```\nUser Key                                (unlocked from your password via SRP)\n └── Address Key                        (passphrase encrypted with User Key)\n      └── Share Key                     (passphrase encrypted with Address Key)\n           └── Node Key per folder/file (passphrase encrypted with parent Node Key)\n                └── Session Key         (stored in ContentKeyPacket, encrypted with Node Key)\n```\n\nTo decrypt any file, the client walks this chain top-down, unlocking each level with the one above.\n\n### File blocks\n\nEach file is split into blocks (≤ 4 MB). Every block is an **OpenPGP SEIPD v1** (tag 18) packet:\n\n```\n[ version: 1 byte ]\n[ CFB-encrypted payload ]\n  ├── prefix: block_size + 2 random bytes  (CFB IV check)\n  ├── Literal Data packet (tag 11)         (actual file content)\n  └── MDC packet (0xd3 0x14 + SHA-1)       (integrity check)\n```\n\nDecryption steps per block:\n1. Verify the block SHA-256 hash against the API-provided value\n2. Decrypt the full ciphertext with AES-CFB (zero IV, session key)\n3. Verify the MDC SHA-1 (covers prefix + literal data + `0xd3 0x14`)\n4. Strip the prefix and parse the Literal Data packet to get raw bytes\n\n### Session key extraction\n\nThe `ContentKeyPacket` is a **PKESK** (tag 1) packet. The session key is ECDH-encrypted with the file's Node Key:\n\n```\nECDH decrypt(Node Key, PKESK)  →  [ algo (1 byte) | key (16/24/32 bytes) | checksum (2 bytes) ]\n```\n\nThe checksum is `sum(key_bytes) mod 65536`. Currently handled by `pgpy` + `cryptography` (see TODO).\n\n## TODO\n\n- [ ] Upload / POST files\n- [ ] Filter the tree with a regex (hide matching paths)\n- [ ] Remove `pgpy` dependency — implement ECDH session key extraction natively with `cryptography`\n\n## License\n\nGPL-3.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenceslas-sanchez%2Fproton-drive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwenceslas-sanchez%2Fproton-drive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenceslas-sanchez%2Fproton-drive/lists"}