Stability | internal |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
public keys and signature algorithms are represented with three different types:
CoseSignAlg
, which is the signature algorithm used, equivalent to a COSE Algorithm from the COSE registryCosePublicKey
, which is a combination of aCoseSignAlg
along with a public key that can be used with it. This is what the COSE_Key CBOR structure decodes toPublicKey
, only the public key part ofCosePublicKey
The following main operations are supported for these types:
CosePublicKey
can be totally decomposed into aCoseSignAlg
withkeySignAlg
and aPublicKey
withfromCose
- A
PublicKey
can be created from an X.509 public key withfromX509
- A
CoseSignAlg
and aPublicKey
can be used to verify a signature withverify
Synopsis
- data PublicKey
- = PublicKeyEdDSA { }
- | PublicKeyECDSA { }
- | PublicKeyRSA { }
- fromCose :: CosePublicKey -> PublicKey
- fromX509 :: PubKey -> Either Text PublicKey
- verify :: CoseSignAlg -> PublicKey -> ByteString -> ByteString -> Either Text ()
- data SomeHashAlgorithm = forall a.HashAlgorithm a => SomeHashAlgorithm a
- toCryptHashECDSA :: CoseHashAlgECDSA -> SomeHashAlgorithm
- data SomeHashAlgorithmASN1 = forall a.HashAlgorithmASN1 a => SomeHashAlgorithmASN1 a
- toCryptHashRSA :: CoseHashAlgRSA -> SomeHashAlgorithmASN1
- toCryptCurveECDSA :: CoseCurveECDSA -> CurveName
- fromCryptCurveECDSA :: CurveName -> Either Text CoseCurveECDSA
Public Key
Same as CosePublicKey
, but without signature algorithm parameters, i.e.
hash algorithms.
PublicKeyEdDSA | |
| |
PublicKeyECDSA | |
| |
PublicKeyRSA | See |
Instances
fromCose :: CosePublicKey -> PublicKey Source #
Turns a CosePublicKey
into a PublicKey
by removing the hash functions
Signature verification
verify :: CoseSignAlg -> PublicKey -> ByteString -> ByteString -> Either Text () Source #
Verifies an asymmetric signature for a message using a CoseSignAlg
and a PublicKey
. Returns an error if the signature algorithm doesn't
match. Also returns an error if the signature wasn't valid or for other
errors.
Hash Conversions to cryptonite types
data SomeHashAlgorithm Source #
Some cryptonite HashAlgorithm
type, used as a return value of toCryptHashECDSA
forall a.HashAlgorithm a => SomeHashAlgorithm a |
toCryptHashECDSA :: CoseHashAlgECDSA -> SomeHashAlgorithm Source #
Returns the cryptonite SomeHashAlgorithm
corresponding to this hash algorithm
data SomeHashAlgorithmASN1 Source #
Some cryptonite HashAlgorithmASN1
type, used as a return value of toCryptHashRSA
forall a.HashAlgorithmASN1 a => SomeHashAlgorithmASN1 a |
toCryptHashRSA :: CoseHashAlgRSA -> SomeHashAlgorithmASN1 Source #
Returns the cryptonite SomeHashAlgorithmASN1
corresponding to this hash algorithm
Conversions from/to cryptonite elliptic curves
toCryptCurveECDSA :: CoseCurveECDSA -> CurveName Source #
Converts a CoseCurveECDSA
to an CurveName
. The inverse
function is fromCryptCurveECDSA
fromCryptCurveECDSA :: CurveName -> Either Text CoseCurveECDSA Source #
Tries to converts a CurveName
to an CoseCurveECDSA
. The inverse
function is toCryptCurveECDSA