### see http://perldoc.perl.org/perlxstypemap.html

###########################
TYPEMAP

Crypt::Cipher           T_PTROBJ
Crypt::Digest           T_PTROBJ
Crypt::Digest::SHAKE    T_PTROBJ

Crypt::Checksum::Adler32 T_PTROBJ
Crypt::Checksum::CRC32  T_PTROBJ

Crypt::AuthEnc::CCM     T_PTROBJ
Crypt::AuthEnc::EAX     T_PTROBJ
Crypt::AuthEnc::GCM     T_PTROBJ
Crypt::AuthEnc::OCB     T_PTROBJ
Crypt::AuthEnc::ChaCha20Poly1305 T_PTROBJ

Crypt::Stream::ChaCha   T_PTROBJ
Crypt::Stream::Salsa20  T_PTROBJ
Crypt::Stream::RC4      T_PTROBJ
Crypt::Stream::Sober128 T_PTROBJ
Crypt::Stream::Sosemanuk T_PTROBJ
Crypt::Stream::Rabbit   T_PTROBJ

Crypt::Mac::F9          T_PTROBJ
Crypt::Mac::HMAC        T_PTROBJ
Crypt::Mac::OMAC        T_PTROBJ
Crypt::Mac::Pelican     T_PTROBJ
Crypt::Mac::PMAC        T_PTROBJ
Crypt::Mac::XCBC        T_PTROBJ
Crypt::Mac::Poly1305    T_PTROBJ
Crypt::Mac::BLAKE2s     T_PTROBJ
Crypt::Mac::BLAKE2b     T_PTROBJ

Crypt::Mode::CBC        T_PTROBJ
Crypt::Mode::CFB        T_PTROBJ
Crypt::Mode::CTR        T_PTROBJ
Crypt::Mode::ECB        T_PTROBJ
Crypt::Mode::F8         T_PTROBJ
Crypt::Mode::LRW        T_PTROBJ
Crypt::Mode::OFB        T_PTROBJ
Crypt::Mode::XTS        T_PTROBJ

Crypt::PRNG             T_PTROBJ

Crypt::PK::RSA          T_PTROBJ
Crypt::PK::DSA          T_PTROBJ
Crypt::PK::ECC          T_PTROBJ
Crypt::PK::DH           T_PTROBJ
Crypt::PK::Ed25519      T_PTROBJ
Crypt::PK::X25519       T_PTROBJ

Math::BigInt::LTM       T_PTROBJ

#pointer with automatic NULL<->undef conversion on input/output
unsigned char *         T_PTR_OR_NULL
char *                  T_STR_OR_NULL
const char *            T_STR_OR_NULL

#perl 5.6.2 hack
STRLEN                  T_UV

###########################
INPUT

T_PTR_OR_NULL
        $var = (SvIOK($arg)) ? INT2PTR($type,SvIVX($arg)) : NULL;

T_STR_OR_NULL
        $var = (SvOK($arg)) ? SvPV_nolen($arg) : NULL; 

###########################
OUTPUT

T_PTR_OR_NULL
        if ($var==NULL) XSRETURN_UNDEF;
        else sv_setiv($arg, PTR2IV($var));

T_STR_OR_NULL
        if ($var==NULL) XSRETURN_UNDEF;
        else sv_setpv($arg, $var);
