ccnumber
ccnumber · data type representing encrypted CC numbers
Overview
Usage
Sources:
- Upstream README at the reviewed commit
- Version 1.0 SQL objects
- Backend implementation
- Comparator implementation
ccnumber is an experimental encrypted byte-string type. PostgreSQL keeps ciphertexts while a separate TCP comparator decrypts and compares them, enabling equality, ordering, B-tree and hash operator classes, and min/max. Upstream explicitly describes the project as a minimally functional, inefficient, generally untested proof of concept; do not use it for payment data or other secrets.
Core Workflow
The project has no SQL plaintext-encryption function. Generate ciphertext with the separately built upstream tool, start ccnumber-comparator, and then provide the ciphertext as bytea-style hex input:
ccnumber.comparator_host defaults to 127.0.0.1, ccnumber.comparator_port to 9999, and ccnumber.optimize_remote_calls to true. Every comparison can depend on the external service; an unavailable comparator makes relevant queries fail.
Security and Operational Boundaries
The reviewed implementation hard-codes the encryption key in the comparator. Its TCP protocol has neither authentication nor transport encryption, so the process acts as a remotely accessible decryption/comparison oracle unless it is strictly isolated. Ordering leaks order; the optimization and hash index leak equality-related information; ciphertexts also add storage overhead.
Both the backend and comparator copy attacker-influenced values into fixed-size buffers without adequate length checks. Arbitrary or oversized ccnumber input can therefore corrupt memory. Treat this code only as a design study in a disposable environment, not as a security control or production extension.