Virgil Security Crypto library  2.0.7
Classes | Enumerations | Functions
Error

This group contains interfaces for error handling mechanism that is used in the library. More...

Classes

class  virgil::crypto::foundation::VirgilSystemCryptoErrorCategory
 Error category that handles error codes from the system crypto library. More...
 
class  virgil::crypto::VirgilCryptoErrorCategory
 This is specific error category that contains information about crypto library errors. More...
 
class  virgil::crypto::VirgilCryptoException
 This only exception that crypto library can produce. More...
 

Enumerations

enum  virgil::crypto::VirgilCryptoError {
  virgil::crypto::VirgilCryptoError::Reserved = 0, virgil::crypto::VirgilCryptoError::EmptyParameter, virgil::crypto::VirgilCryptoError::ExceededMaxSize, virgil::crypto::VirgilCryptoError::InvalidArgument,
  virgil::crypto::VirgilCryptoError::InvalidFormat, virgil::crypto::VirgilCryptoError::InvalidPrivateKey, virgil::crypto::VirgilCryptoError::InvalidPrivateKeyPassword, virgil::crypto::VirgilCryptoError::InvalidPublicKey,
  virgil::crypto::VirgilCryptoError::InvalidSignature, virgil::crypto::VirgilCryptoError::InvalidState, virgil::crypto::VirgilCryptoError::InvalidAuth, virgil::crypto::VirgilCryptoError::MismatchSignature,
  virgil::crypto::VirgilCryptoError::NotFoundKeyRecipient, virgil::crypto::VirgilCryptoError::NotFoundPasswordRecipient, virgil::crypto::VirgilCryptoError::NotInitialized, virgil::crypto::VirgilCryptoError::NotSecure,
  virgil::crypto::VirgilCryptoError::UnsupportedAlgorithm, Undefined = std::numeric_limits<int>::max()
}
 Specific error codes for the crypto library. More...
 

Functions

const VirgilSystemCryptoErrorCategory & virgil::crypto::foundation::system_crypto_category () noexcept
 Return singleton instance of the system crypto error category. More...
 
int virgil::crypto::foundation::system_crypto_handler_get_result (int result)
 Handle value returned by underling system crypto library. More...
 
void virgil::crypto::foundation::system_crypto_handler (int result)
 Handle value returned by underling system crypto library. More...
 
template<typename CatchHandler >
int virgil::crypto::foundation::system_crypto_handler_get_result (int result, CatchHandler catch_handler)
 Handle value returned by underling system crypto library. More...
 
template<typename CatchHandler >
void virgil::crypto::foundation::system_crypto_handler (int result, CatchHandler catch_handler)
 Handle value returned by underling system crypto library. More...
 
const VirgilCryptoErrorCategory & virgil::crypto::crypto_category () noexcept
 Return singleton instance of the crypto error category. More...
 
VirgilCryptoException virgil::crypto::make_error (VirgilCryptoError ev)
 Build exception with given error value and corresond error category. More...
 
VirgilCryptoException virgil::crypto::make_error (VirgilCryptoError ev, const std::string &what)
 Build exception with given error value and corresond error category. More...
 
VirgilCryptoException virgil::crypto::make_error (VirgilCryptoError ev, const char *what)
 Build exception with given error value and corresond error category. More...
 

Detailed Description

This group contains interfaces for error handling mechanism that is used in the library.

Enumeration Type Documentation

Specific error codes for the crypto library.

Enumerator
Reserved 

Should not be used.

EmptyParameter 

Given parameter is null or empty.

ExceededMaxSize 

Structure maximum size was exceeded.

InvalidArgument 

Argument given to a function is invalid.

InvalidFormat 

Data format is invalid.

InvalidPrivateKey 

Invalid format of the Private Key.

InvalidPrivateKeyPassword 

Private Key password mismatch.

InvalidPublicKey 

Invalid format of the Public Key.

InvalidSignature 

Invalid format of the Signature.

InvalidState 

Function call prerequisite is broken.

InvalidAuth 

Invalid authentication.

MismatchSignature 

Signature validation failed.

NotFoundKeyRecipient 

Recipient with given identifier is not found.

NotFoundPasswordRecipient 

Recipient with given password is not found.

NotInitialized 

Object is not initialized with specific algorithm, so can't be used.

NotSecure 

Security prerequisite is broken.

UnsupportedAlgorithm 

Algorithm is not supported in the current build.

Function Documentation

const VirgilCryptoErrorCategory& virgil::crypto::crypto_category ( )
noexcept

Return singleton instance of the crypto error category.

Returns
Instance of the crypto error categoty.
VirgilCryptoException virgil::crypto::make_error ( VirgilCryptoError  ev)
inline

Build exception with given error value and corresond error category.

Parameters
evError value.
Returns
Exception with given error value and corresond error category.
See also
VirgilCryptoError for specific Error values.
VirgilCryptoException virgil::crypto::make_error ( VirgilCryptoError  ev,
const std::string &  what 
)
inline

Build exception with given error value and corresond error category.

Parameters
evError value.
whatAdditional error description.
Returns
Exception with given error value and corresond error category.
See also
VirgilCryptoError for specific Error values.
VirgilCryptoException virgil::crypto::make_error ( VirgilCryptoError  ev,
const char *  what 
)
inline

Build exception with given error value and corresond error category.

Parameters
evError value.
whatAdditional error description.
Returns
Exception with given error value and corresond error category.
See also
VirgilCryptoError for specific Error values.
const VirgilSystemCryptoErrorCategory& virgil::crypto::foundation::system_crypto_category ( )
noexcept

Return singleton instance of the system crypto error category.

Returns
Instance of the syste, crypto error categoty.
void virgil::crypto::foundation::system_crypto_handler ( int  result)
inline

Handle value returned by underling system crypto library.

If given value is an error then VirgilCryptoException will be thrown with appropriate description. If given value is not an error then do nothing.

Parameters
resultValue returned by system crypto library.
Exceptions
VirgilCryptoExceptionwith given error code and correspond category, if given value represents an error.
template<typename CatchHandler >
void virgil::crypto::foundation::system_crypto_handler ( int  result,
CatchHandler  catch_handler 
)
inline

Handle value returned by underling system crypto library.

This function is usefull if thrown exception SHOULD be wrapped or error can be handled in a different way. Initial exception can be accessed via std::current_exception(), or std::throw_with_nested().

If given value is an error then VirgilCryptoException will be thrown with appropriate description. If given value is not an error then do nothing.

Parameters
resultValue returned by system crypto library.
catch_handlerFunction that can handle the error in a different way.
int virgil::crypto::foundation::system_crypto_handler_get_result ( int  result)
inline

Handle value returned by underling system crypto library.

If given value is an error then VirgilCryptoException will be thrown with appropriate description. If given value is not an error then it will be returned.

Parameters
resultValue returned by system crypto library.
Returns
Value if it's not an error.
Exceptions
VirgilCryptoExceptionwith given error code and correspond category, if given value represents an error.
template<typename CatchHandler >
int virgil::crypto::foundation::system_crypto_handler_get_result ( int  result,
CatchHandler  catch_handler 
)
inline

Handle value returned by underling system crypto library.

This function is usefull if thrown exception SHOULD be wrapped. Initial exception can be accessed via std::current_exception(), or std::throw_with_nested().

If given value is an error then VirgilCryptoException will be thrown with appropriate description. If given value is not an error then it will be returned.

Parameters
resultValue returned by system crypto library.
catch_handlerFunction that can handle the error in a different way.
Returns
Value if it's not an error.