hspkcs11-0.3: Wrapper for PKCS #11 interface

Safe HaskellNone
LanguageHaskell2010

System.Crypto.Pkcs11

Contents

Synopsis

Library

loadLibrary :: String -> IO Library Source #

Load PKCS#11 dynamically linked library

lib <- loadLibrary "/path/to/dll.so"

Reading library information

data Info Source #

Instances

Show Info Source # 

Methods

showsPrec :: Int -> Info -> ShowS #

show :: Info -> String #

showList :: [Info] -> ShowS #

Storable Info Source # 

Methods

sizeOf :: Info -> Int #

alignment :: Info -> Int #

peekElemOff :: Ptr Info -> Int -> IO Info #

pokeElemOff :: Ptr Info -> Int -> Info -> IO () #

peekByteOff :: Ptr b -> Int -> IO Info #

pokeByteOff :: Ptr b -> Int -> Info -> IO () #

peek :: Ptr Info -> IO Info #

poke :: Ptr Info -> Info -> IO () #

getInfo :: Library -> IO Info Source #

Returns general information about Cryptoki

infoCryptokiVersion :: Info -> Version Source #

Cryptoki interface version number, for compatibility with future revisions of this interface

infoManufacturerId :: Info -> String Source #

ID of the Cryptoki library manufacturer

infoFlags :: Info -> Int Source #

bit flags reserved for future versions. Must be zero for this version

infoLibraryVersion :: Info -> Version Source #

Cryptoki library version number

Slots

getSlotList :: Library -> Bool -> Int -> IO [SlotId] Source #

Allows to obtain a list of slots in the system

slotsIds <- getSlotList lib True 10

In this example retrieves list of, at most 10 (third parameter) slot identifiers with tokens present (second parameter is set to True)

Reading slot information

getSlotInfo :: Library -> SlotId -> IO SlotInfo Source #

Obtains information about a particular slot in the system

slotInfo <- getSlotInfo lib slotId

slotInfoFlags :: SlotInfo -> Int Source #

bit flags indicating capabilities and status of the slot as defined in https://www.cryptsoft.com/pkcs11doc/v220/pkcs11__all_8h.html#aCK_SLOT_INFO

Reading token information

getTokenInfo :: Library -> SlotId -> IO TokenInfo Source #

Obtains information about a particular token in the system

tokenInfo <- getTokenInfo lib slotId

tokenInfoFlags :: TokenInfo -> Int Source #

bit flags indicating capabilities and status of the device as defined in https://www.cryptsoft.com/pkcs11doc/v220/pkcs11__all_8h.html#aCK_TOKEN_INFO

Mechanisms

getMechanismList :: Library -> SlotId -> Int -> IO [Int] Source #

Obtains a list of mechanism types supported by a token

getMechanismInfo :: Library -> SlotId -> MechType -> IO MechInfo Source #

Obtains information about a particular mechanism possibly supported by a token

Session management

withSession :: Library -> SlotId -> Bool -> (Session -> IO a) -> IO a Source #

Object attributes

Searching objects

Reading object attributes

Key generation

Key wrapping/unwrapping

Encryption/decryption

Misc