Files
secpaste/crypto/base.py
nanoclaw ff41256f2f Initial commit: SecPaste encrypted pastebin client
SecPaste is a Python library and CLI tool for sharing encrypted content via
public pastebin services with zero-knowledge architecture.

Features:
- Pluggable crypto backends (AES-256-GCM, ChaCha20-Poly1305, Kyber-768)
- Pluggable pastebin providers (dpaste.com, extensible)
- URL fragment key storage (key never sent to server)
- Both CLI and library usage
- Post-quantum cryptography support (experimental)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-07 22:52:32 +00:00

41 lines
956 B
Python

"""Base cryptographic interface for SecPaste."""
from abc import ABC, abstractmethod
from typing import Tuple
class CipherBackend(ABC):
"""Abstract base class for cipher implementations."""
@abstractmethod
def encrypt(self, plaintext: bytes) -> Tuple[bytes, str]:
"""
Encrypt plaintext data.
Args:
plaintext: Raw bytes to encrypt
Returns:
Tuple of (ciphertext, key) where key is base64url-encoded
"""
pass
@abstractmethod
def decrypt(self, ciphertext: bytes, key: str) -> bytes:
"""
Decrypt ciphertext using the provided key.
Args:
ciphertext: Encrypted data
key: Base64url-encoded encryption key
Returns:
Decrypted plaintext bytes
"""
pass
@abstractmethod
def get_name(self) -> str:
"""Return the name/identifier of this cipher backend."""
pass