58 lines
3.1 KiB
Plaintext
58 lines
3.1 KiB
Plaintext
from openssl.types import *
|
|
|
|
# ============================================================
|
|
# openssl/pem.vp — PEM encoding/decoding
|
|
# Corresponding header: pem.h
|
|
#
|
|
# Everything takes BIO input (PEM_read_bio_*); the x out-parameter for certificates/keys may be NULL
|
|
# (the function returns a new object). Callback cb uses bytes (Viper passes t.CPtr(0)).
|
|
# ============================================================
|
|
|
|
# ---- X509 certificate ----
|
|
# X509 *PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u)
|
|
extern def PEM_read_bio_X509(bp: BioPtr, x: bytes, cb: bytes, u: bytes) -> X509Ptr
|
|
# int PEM_write_bio_X509(BIO *bp, X509 *x)
|
|
extern def PEM_write_bio_X509(bp: BioPtr, x: X509Ptr) -> int
|
|
# X509 *PEM_read_bio_X509_AUX(BIO *bp, X509 **x, pem_password_cb *cb, void *u)
|
|
extern def PEM_read_bio_X509_AUX(bp: BioPtr, x: bytes, cb: bytes, u: bytes) -> X509Ptr
|
|
# int PEM_write_bio_X509_AUX(BIO *bp, X509 *x)
|
|
extern def PEM_write_bio_X509_AUX(bp: BioPtr, x: X509Ptr) -> int
|
|
|
|
# ---- Private / public key (generic EVP_PKEY container) ----
|
|
# EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u)
|
|
extern def PEM_read_bio_PrivateKey(bp: BioPtr, x: bytes, cb: bytes, u: bytes) -> EvpPkeyPtr
|
|
# int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
|
|
# const unsigned char *kstr, int klen, pem_password_cb *cb, void *u)
|
|
extern def PEM_write_bio_PrivateKey(bp: BioPtr, x: EvpPkeyPtr, enc: EvpCipherPtr,
|
|
kstr: bytes, klen: int, cb: bytes, u: bytes) -> int
|
|
# EVP_PKEY *PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u)
|
|
extern def PEM_read_bio_PUBKEY(bp: BioPtr, x: bytes, cb: bytes, u: bytes) -> EvpPkeyPtr
|
|
# int PEM_write_bio_PUBKEY(BIO *bp, EVP_PKEY *x)
|
|
extern def PEM_write_bio_PUBKEY(bp: BioPtr, x: EvpPkeyPtr) -> int
|
|
|
|
# ---- Legacy RSA private key (still exported in OpenSSL 3.x, for old files) ----
|
|
# RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **x, pem_password_cb *cb, void *u)
|
|
extern def PEM_read_bio_RSAPrivateKey(bp: BioPtr, x: bytes, cb: bytes, u: bytes) -> bytes
|
|
# int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc,
|
|
# const unsigned char *kstr, int klen, pem_password_cb *cb, void *u)
|
|
extern def PEM_write_bio_RSAPrivateKey(bp: BioPtr, x: bytes, enc: EvpCipherPtr,
|
|
kstr: bytes, klen: int, cb: bytes, u: bytes) -> int
|
|
|
|
# ---- Certificate request / CRL ----
|
|
# X509_REQ *PEM_read_bio_X509_REQ(BIO *bp, X509_REQ **x, pem_password_cb *cb, void *u)
|
|
extern def PEM_read_bio_X509_REQ(bp: BioPtr, x: bytes, cb: bytes, u: bytes) -> X509ReqPtr
|
|
# X509_CRL *PEM_read_bio_X509_CRL(BIO *bp, X509_CRL **x, pem_password_cb *cb, void *u)
|
|
extern def PEM_read_bio_X509_CRL(bp: BioPtr, x: bytes, cb: bytes, u: bytes) -> X509CrlPtr
|
|
|
|
# ---- Convenience readers (caller passes no x out-param / cb) ----
|
|
def pem_read_bio_x509_simple(bp: BioPtr) -> X509Ptr:
|
|
return PEM_read_bio_X509(bp, None, None, None)
|
|
|
|
|
|
def pem_read_bio_privkey_simple(bp: BioPtr) -> EvpPkeyPtr:
|
|
return PEM_read_bio_PrivateKey(bp, None, None, None)
|
|
|
|
|
|
def pem_read_bio_pubkey_simple(bp: BioPtr) -> EvpPkeyPtr:
|
|
return PEM_read_bio_PUBKEY(bp, None, None, None)
|