Modulehackage-security-0.6.4.0Haskell2010
Hackage.Security.Server
Main entry point into the Hackage Security framework for clients
- 51 types
- 4 classes
- 53 values
- Packagehackage-security-0.6.4.0
- Exports108
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceServer.hs
Re-exports
108 declarationsRender to canonical JSON format
Variation on renderJSON for files that don't require the repo layout
Constructors
DeserializationErrorMalformed StringMalformed JSON has syntax errors in the JSON itself (i.e., we cannot even parse it to a JSValue)
DeserializationErrorSchema StringInvalid JSON has valid syntax but invalid structure
The string gives a hint about what we expected instead
DeserializationErrorUnknownKey KeyIdThe JSON file contains a key ID of an unknown key
DeserializationErrorValidation StringSome verification step failed
DeserializationErrorFileType String StringWrong file type
Records actual and expected types.
Instances6Show, Exception, Pretty, MonadError
Show DeserializationErrorDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONException DeserializationErrorDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONPretty DeserializationErrorDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadError DeserializationError ReadJSON_Keys_LayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadError DeserializationError ReadJSON_Keys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadError DeserializationError ReadJSON_NoKeys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSON
Instances7Monad, Functor, Applicative, MonadKeys, ReportSchemaErrors, MonadError, …
Monad ReadJSON_Keys_LayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONFunctor ReadJSON_Keys_LayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONApplicative ReadJSON_Keys_LayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadKeys ReadJSON_Keys_LayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONReportSchemaErrors ReadJSON_Keys_LayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadError DeserializationError ReadJSON_Keys_LayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadReader RepoLayout ReadJSON_Keys_LayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSON
Instances6Monad, Functor, Applicative, MonadKeys, ReportSchemaErrors, MonadError
Monad ReadJSON_Keys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONFunctor ReadJSON_Keys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONApplicative ReadJSON_Keys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadKeys ReadJSON_Keys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONReportSchemaErrors ReadJSON_Keys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadError DeserializationError ReadJSON_Keys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSON
Instances5Monad, Functor, Applicative, ReportSchemaErrors, MonadError
Monad ReadJSON_NoKeys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONFunctor ReadJSON_NoKeys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONApplicative ReadJSON_NoKeys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONReportSchemaErrors ReadJSON_NoKeys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadError DeserializationError ReadJSON_NoKeys_NoLayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSON
Instances4Monad, Functor, Applicative, MonadReader
Monad WriteJSONDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONFunctor WriteJSONDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONApplicative WriteJSONDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadReader RepoLayout WriteJSONDefined in hackage-security-0.6.4.0 · Hackage.Security.JSON
Instances39FromJSON, …
Monad m => FromJSON m JSValueDefined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSONMonadKeys m => FromJSON m RootRolesDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootMonadKeys m => FromJSON m SignaturesDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SignedMonadKeys m => FromJSON m DelegationSpecDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonadKeys m => FromJSON m DelegationsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonadKeys m => FromJSON m TargetsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsReportSchemaErrors m => FromJSON m StringDefined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSONReportSchemaErrors m => FromJSON m KeyEnvDefined in hackage-security-0.6.4.0 · Hackage.Security.Key.EnvReportSchemaErrors m => FromJSON m FileLengthDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonReportSchemaErrors m => FromJSON m HashDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonReportSchemaErrors m => FromJSON m KeyThresholdDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonReportSchemaErrors m => FromJSON m FileInfoDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileInfoReportSchemaErrors m => FromJSON m FileMapDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileMapReportSchemaErrors m => FromJSON m FileExpiresDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderReportSchemaErrors m => FromJSON m FileVersionDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderReportSchemaErrors m => FromJSON m HeaderDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderReportSchemaErrors m => FromJSON m MirrorDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.MirrorsReportSchemaErrors m => FromJSON m PreSignatureDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SignedReportSchemaErrors m => FromJSON m Base64Defined in hackage-security-0.6.4.0 · Hackage.Security.Util.Base64ReportSchemaErrors m => FromJSON m Int54Defined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSONReportSchemaErrors m => FromJSON m URIDefined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSONReportSchemaErrors m => FromJSON m UTCTimeDefined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSON(MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m MirrorsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Mirrors(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m SnapshotDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Snapshot(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m TimestampDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TimestampMonadKeys m => FromJSON m (RoleSpec a)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootMonadKeys m => FromJSON m (Signed Mirrors)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.MirrorsMonadKeys m => FromJSON m (Signed Root)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootWe give an instance for Signed Root rather than Root because the key environment from the root data is necessary to resolve the explicit sharing in the signatures.
MonadKeys m => FromJSON m (Signed Targets)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsReportSchemaErrors m => FromJSON m (Some Key)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyReportSchemaErrors m => FromJSON m (Some KeyType)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyReportSchemaErrors m => FromJSON m (Some PublicKey)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyReportSchemaErrors m => FromJSON m (Some Pattern)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.PatternsReportSchemaErrors m => FromJSON m (Some Replacement)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Patterns(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Snapshot)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Snapshot(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Timestamp)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Timestamp(ReportSchemaErrors m, FromJSON m a) => FromJSON m (UninterpretedSignatures a)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Signed(ReportSchemaErrors m, FromJSON m a) => FromJSON m [a]Defined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSON(ReportSchemaErrors m, Ord k, FromObjectKey m k, FromJSON m a) => FromJSON m (Map k a)Defined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSON
Instances40ToJSON, …
Monad m => ToJSON m StringDefined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSONMonad m => ToJSON m KeyEnvDefined in hackage-security-0.6.4.0 · Hackage.Security.Key.EnvMonad m => ToJSON m FileLengthDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonMonad m => ToJSON m HashDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonMonad m => ToJSON m KeyThresholdDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonMonad m => ToJSON m FileInfoDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileInfoMonad m => ToJSON m FileMapDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileMapMonad m => ToJSON m FileExpiresDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderMonad m => ToJSON m FileVersionDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderMonad m => ToJSON m MirrorDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.MirrorsMonad m => ToJSON m MirrorsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.MirrorsMonad m => ToJSON m RootDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootMonad m => ToJSON m RootRolesDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootMonad m => ToJSON m PreSignatureDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SignedMonad m => ToJSON m SignaturesDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SignedMonad m => ToJSON m DelegationSpecDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonad m => ToJSON m DelegationsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonad m => ToJSON m TargetsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonad m => ToJSON m Base64Defined in hackage-security-0.6.4.0 · Hackage.Security.Util.Base64Monad m => ToJSON m Int54Defined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSONMonad m => ToJSON m JSValueDefined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSONMonad m => ToJSON m URIDefined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSONMonad m => ToJSON m UTCTimeDefined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSONMonadReader RepoLayout m => ToJSON m SnapshotDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SnapshotMonadReader RepoLayout m => ToJSON m TimestampDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TimestampMonad m => ToJSON m (Key typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (KeyType typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (PublicKey typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (Pattern typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.PatternsMonad m => ToJSON m (Replacement typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.PatternsMonad m => ToJSON m (RoleSpec a)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootMonad m => ToJSON m (Some Key)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (Some KeyType)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (Some PublicKey)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (Some Pattern)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.PatternsMonad m => ToJSON m (Some Replacement)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Patterns(Monad m, ToJSON m a) => ToJSON m (Signed a)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Signed(Monad m, ToJSON m a) => ToJSON m (UninterpretedSignatures a)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Signed(Monad m, ToJSON m a) => ToJSON m [a]Defined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSON(Monad m, ToObjectKey m k, ToJSON m a) => ToJSON m (Map k a)Defined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSON
Sign a bytestring and return the signature
TODO: It is unfortunate that we have to convert to a strict bytestring for ed25519
Constructors
KeyEd25519 :: PublicKey -> SecretKey -> Key Ed25519
Instances10HasKeyId, SomeEq, SomeShow, Typed, FromJSON, ToJSON, …
HasKeyId KeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeySomeEq KeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeySomeShow KeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyTyped KeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyReportSchemaErrors m => FromJSON m (Some Key)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (Key typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (Some Key)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyEq (Key typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyShow (Key typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.Keytype TypeOf Key = KeyTypeDefined in hackage-security-0.6.4.0 · Hackage.Security.Key
The key ID of a key, by definition, is the hexdigest of the SHA-256 hash of the canonical JSON form of the key where the private object key is excluded.
NOTE: The FromJSON and ToJSON instances for KeyId are intentionally omitted. Use writeKeyAsId instead.
Constructors
Instances5Eq, Ord, Show, FromObjectKey, ToObjectKey
Eq KeyIdDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyOrd KeyIdDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyShow KeyIdDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => FromObjectKey m KeyIdDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToObjectKey m KeyIdDefined in hackage-security-0.6.4.0 · Hackage.Security.Key
Constructors
Instances8Unify, SomeEq, SomeShow, FromJSON, ToJSON, Eq, …
Unify KeyTypeDefined in hackage-security-0.6.4.0 · Hackage.Security.KeySomeEq KeyTypeDefined in hackage-security-0.6.4.0 · Hackage.Security.KeySomeShow KeyTypeDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyReportSchemaErrors m => FromJSON m (Some KeyType)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (KeyType typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (Some KeyType)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyEq (KeyType typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyShow (KeyType typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.Key
Constructors
Instances6SomeEq, SomeShow, Typed, Eq, Show, TypeOf
SomeEq PrivateKeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeySomeShow PrivateKeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyTyped PrivateKeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyEq (PrivateKey typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyShow (PrivateKey typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.Keytype TypeOf PrivateKey = KeyTypeDefined in hackage-security-0.6.4.0 · Hackage.Security.Key
Constructors
Instances10HasKeyId, SomeEq, SomeShow, Typed, FromJSON, ToJSON, …
HasKeyId PublicKeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeySomeEq PublicKeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeySomeShow PublicKeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyTyped PublicKeyDefined in hackage-security-0.6.4.0 · Hackage.Security.KeyReportSchemaErrors m => FromJSON m (Some PublicKey)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (PublicKey typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyMonad m => ToJSON m (Some PublicKey)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyEq (PublicKey typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.KeyShow (PublicKey typ)Defined in hackage-security-0.6.4.0 · Hackage.Security.Keytype TypeOf PublicKey = KeyTypeDefined in hackage-security-0.6.4.0 · Hackage.Security.Key
Compute FileInfo
Compute FileInfo
TODO: Currently this will load the entire input bytestring into memory. We need to make this incremental, by computing the length and all hashes in a single traversal over the input.
Extract SHA256 hash from FileInfo (if present)
The cache layout cabal-install uses
We cache the index as cache/00-index.tar; this is important because
`cabal-install` expects to find it there (and does not currently go through
the hackage-security library to get files from the index).
The layout of the index as maintained on Hackage
Layout used by cabal for ("legacy") local repos
Obviously, such repos do not normally contain any of the TUF files, so their location is more or less arbitrary here.
The layout used on Hackage
Give a human-readable description of a particular mirror
(for use in error messages)
Anchor a cache path to the location of the cache
Convert a pre-signature to a signature
Verifies that the key type matches the advertised method.
Convert a list of PreSignatures to a list of Signatures
This verifies the invariant that all signatures are made with different keys. We do this on the presignatures rather than the signatures so that we can do the check on key IDs, rather than keys (the latter don't have an Ord instance).
Construct signatures for already rendered value
General FromJSON instance for signed datatypes
We don't give a general FromJSON instance for Signed because for some datatypes we need to do something special (datatypes where we need to read key environments); for instance, see the "Signed Root" instance.
Convert signature to pre-signature
Convert list of pre-signatures to a list of signatures
Create a new document without any signatures
Signature verification
NOTES: 1. By definition, the signature must be verified against the canonical JSON format. This means we _must_ parse and then pretty print (as we do here) because the document as stored may or may not be in canonical format. 2. However, it is important that we NOT translate from the JSValue to whatever internal datatype we are using and then back to JSValue, because that may not roundtrip: we must allow for additional fields in the JSValue that we ignore (and would therefore lose when we attempt to roundtrip). 3. We verify that all signatures are valid, but we cannot verify (here) that these signatures are signed with the right key, or that we have a sufficient number of signatures. This will be the responsibility of the calling code.
Sign a document
Variation on withSignatures that doesn't need the repo layout
File length
Having verified file length information means we can protect against endless data attacks and similar.
Constructors
Instances5Eq, Ord, Show, FromJSON, ToJSON
Eq FileLengthDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonOrd FileLengthDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonShow FileLengthDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonReportSchemaErrors m => FromJSON m FileLengthDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonMonad m => ToJSON m FileLengthDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Common
Instances5Eq, Ord, Show, FromJSON, ToJSON
Eq HashDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonOrd HashDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonShow HashDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonReportSchemaErrors m => FromJSON m HashDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonMonad m => ToJSON m HashDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Common
Key threshold
The key threshold is the minimum number of keys a document must be signed
with. Key thresholds are specified in RoleSpec or DelegationsSpec.
Constructors
Instances5Eq, Ord, Show, FromJSON, ToJSON
Eq KeyThresholdDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonOrd KeyThresholdDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonShow KeyThresholdDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonReportSchemaErrors m => FromJSON m KeyThresholdDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.CommonMonad m => ToJSON m KeyThresholdDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Common
File information
This intentionally does not have an Eq instance; see knownFileInfoEqual
and verifyFileInfo instead.
NOTE: Throughout we compute file information always over the raw bytes.
For example, when timestamp.json lists the hash of snapshot.json, this
hash is computed over the actual snapshot.json file (as opposed to the
canonical form of the embedded JSON). This brings it in line with the hash
computed over target files, where that is the only choice available.
Constructors
Instances3Show, FromJSON, ToJSON
Instances5Eq, Ord, Show, FromObjectKey, ToObjectKey
Eq HashFnDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileInfoOrd HashFnDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileInfoShow HashFnDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileInfoReportSchemaErrors m => FromObjectKey m HashFnDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileInfoMonad m => ToObjectKey m HashFnDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileInfo
Constructors
FileChanged FileInfoFile got added or modified; we record the new file info
FileDeletedFile got deleted
Instances1Show
Show FileChangeDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileMap
Mapping from paths to file info
File maps are used in target files; the paths are relative to the location of the target files containing the file map.
Instances3Show, FromJSON, ToJSON
Entries in FileMap either talk about the repository or the index
Constructors
Instances6Eq, Ord, Show, Pretty, FromObjectKey, ToObjectKey
Eq TargetPathDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileMapOrd TargetPathDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileMapShow TargetPathDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileMapPretty TargetPathDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileMapReportSchemaErrors m => FromObjectKey m TargetPathDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileMapMonad m => ToObjectKey m TargetPathDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.FileMap
File expiry date
A Nothing value here means no expiry. That makes it possible to set some files to never expire. (Note that not having the Maybe in the type here still allows that, because you could set an expiry date 2000 years into the future. By having the Maybe here we avoid the _need_ for such encoding issues.)
Constructors
Instances5Eq, Ord, Show, FromJSON, ToJSON
Eq FileExpiresDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderOrd FileExpiresDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderShow FileExpiresDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderReportSchemaErrors m => FromJSON m FileExpiresDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderMonad m => ToJSON m FileExpiresDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Header
File version
The file version is a flat integer which must monotonically increase on every file update.
Show and Read instance are defined in terms of the underlying Int (this is used for example by Hackage during the backup process).
Constructors
Instances6Eq, Ord, Read, Show, FromJSON, ToJSON
Eq FileVersionDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderOrd FileVersionDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderRead FileVersionDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderShow FileVersionDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderReportSchemaErrors m => FromJSON m FileVersionDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderMonad m => ToJSON m FileVersionDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Header
Methods
fileExpires :: Lens' a FileExpiresFile expiry date
fileVersion :: Lens' a FileVersionFile version (monotonically increasing counter)
Instances6HasHeader
HasHeader HeaderDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderHasHeader MirrorsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.MirrorsHasHeader RootDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootHasHeader SnapshotDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SnapshotHasHeader TargetsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsHasHeader TimestampDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Timestamp
Occasionally it is useful to read only a header from a file.
HeaderOnly intentionally only has a FromJSON instance (no ToJSON).
Constructors
Instances2HasHeader, FromJSON
HasHeader HeaderDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.HeaderReportSchemaErrors m => FromJSON m HeaderDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Header
Location of the various files we cache
Although the generic TUF algorithms do not care how we organize the cache,
we nonetheless specify this here because as long as there are tools which
access files in the cache directly we need to define the cache layout.
See also comments for defaultCacheLayout.
Constructors
CacheLayoutcacheLayoutRoot :: CachePathTUF root metadata
cacheLayoutTimestamp :: CachePathTUF timestamp
cacheLayoutSnapshot :: CachePathTUF snapshot
cacheLayoutMirrors :: CachePathTUF mirrors list
cacheLayoutIndexTar :: CachePathUncompressed index tarball
cacheLayoutIndexIdx :: CachePathIndex to the uncompressed index tarball
cacheLayoutIndexTarGz :: CachePathCompressed index tarball
We cache both the compressed and the uncompressed tarballs, because incremental updates happen through the compressed tarball, but reads happen through the uncompressed one (with the help of the tarball index).
Files that we might request from the index
The type index tells us the type of the decoded file, if any. For files for
which the library does not support decoding this will be ().
NOTE: Clients should NOT rely on this type index being (), or they might
break if we add support for parsing additional file formats in the future.
TODO: If we wanted to support legacy Hackage, we should also have a case for the global preferred-versions file. But supporting legacy Hackage will probably require more work anyway..
Constructors
IndexPkgMetadata :: PackageIdentifier -> IndexFile (Signed Targets)IndexPkgCabal :: PackageIdentifier -> IndexFile ()IndexPkgPrefs :: PackageName -> IndexFile ()
Instances4SomePretty, SomeShow, Show, Pretty
SomePretty IndexFileDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Layout.IndexSomeShow IndexFileDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Layout.IndexShow (IndexFile dec)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Layout.IndexPretty (IndexFile dec)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Layout.Index
Layout of the files within the index tarball
Constructors
IndexLayoutindexFileToPath :: forall dec. IndexFile dec -> IndexPathTranslate an IndexFile to a path
indexFileFromPath :: IndexPath -> Maybe (Some IndexFile)Parse an FilePath
Layout of a repository
Constructors
RepoLayoutrepoLayoutRoot :: RepoPathTUF root metadata
repoLayoutTimestamp :: RepoPathTUF timestamp
repoLayoutSnapshot :: RepoPathTUF snapshot
repoLayoutMirrors :: RepoPathTUF mirrors list
repoLayoutIndexTarGz :: RepoPathCompressed index tarball
repoLayoutIndexTar :: RepoPathUncompressed index tarball
repoLayoutPkgTarGz :: PackageIdentifier -> RepoPathPath to the package tarball
Instances2MonadReader
MonadReader RepoLayout ReadJSON_Keys_LayoutDefined in hackage-security-0.6.4.0 · Hackage.Security.JSONMonadReader RepoLayout WriteJSONDefined in hackage-security-0.6.4.0 · Hackage.Security.JSON
Definition of a mirror
NOTE: Unlike the TUF specification, we require that all mirrors must have
the same format. That is, we omit metapath and targetspath.
Constructors
Instances3Show, FromJSON, ToJSON
Full versus partial mirrors
The TUF spec explicitly allows for partial mirrors, with the mirrors file specifying (through patterns) what is available from partial mirrors.
For now we only support full mirrors; if we wanted to add partial mirrors,
we would add a second MirrorPartial constructor here with arguments
corresponding to TUF's metacontent and targetscontent fields.
Instances1Show
Show MirrorContentDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Mirrors
Constructors
Instances5HasHeader, VerifyRole, ToJSON, FromJSON
HasHeader MirrorsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.MirrorsVerifyRole MirrorsDefined in hackage-security-0.6.4.0 · Hackage.Security.Trusted(MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m MirrorsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.MirrorsMonad m => ToJSON m MirrorsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.MirrorsMonadKeys m => FromJSON m (Signed Mirrors)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Mirrors
The cache directory
Paths relative to the root of the index tarball
The root of the index tarball
Paths relative to the root of the repository
The root of the repository
Repository roots can be anchored at a remote URL or a local directory.
Note that even for remote repos RepoRoot is (potentially) different from
Web -- for a repository located at, say, http://hackage.haskell.org
they happen to coincide, but for one location at
http://example.com/some/subdirectory they do not.
A delegation
A delegation is a pair of a pattern and a replacement.
See match for an example.
Constructors
forall a. Delegation (Pattern a) (Replacement a)
Instances2Show, Lift
Show DelegationDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.PatternsLift DelegationDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Patterns
Role specification
The phantom type indicates what kind of type this role is meant to verify.
Constructors
Instances3FromJSON, ToJSON, Show
The root metadata
NOTE: We must have the invariant that ALL keys (apart from delegation keys) must be listed in rootKeys. (Delegation keys satisfy a similar invariant, see Targets.)
Constructors
Instances4HasHeader, VerifyRole, ToJSON, FromJSON
HasHeader RootDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootVerifyRole RootDefined in hackage-security-0.6.4.0 · Hackage.Security.TrustedMonad m => ToJSON m RootDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootMonadKeys m => FromJSON m (Signed Root)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootWe give an instance for Signed Root rather than Root because the key environment from the root data is necessary to resolve the explicit sharing in the signatures.
A signature with a key ID (rather than an actual key)
This corresponds precisely to the TUF representation of a signature.
Constructors
Instances3Show, FromJSON, ToJSON
Show PreSignatureDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SignedReportSchemaErrors m => FromJSON m PreSignatureDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SignedMonad m => ToJSON m PreSignatureDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Signed
Constructors
A list of signatures
Invariant: each signature must be made with a different key. We enforce this invariant for incoming untrusted data (fromPreSignatures) but not for lists of signatures that we create in code.
Constructors
Instances2FromJSON, ToJSON
MonadKeys m => FromJSON m SignaturesDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SignedMonad m => ToJSON m SignaturesDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Signed
Constructors
Signedsigned :: asignatures :: Signatures
Instances6FromJSON, ToJSON
MonadKeys m => FromJSON m (Signed Mirrors)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.MirrorsMonadKeys m => FromJSON m (Signed Root)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.RootWe give an instance for Signed Root rather than Root because the key environment from the root data is necessary to resolve the explicit sharing in the signatures.
MonadKeys m => FromJSON m (Signed Targets)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Targets(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Snapshot)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Snapshot(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Timestamp)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Timestamp(Monad m, ToJSON m a) => ToJSON m (Signed a)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Signed
File with uninterpreted signatures
Sometimes we want to be able to read a file without interpreting the signatures (that is, resolving the key IDs) or doing any kind of checks on them. One advantage of this is that this allows us to read many file types without any key environment at all, which is sometimes useful.
Constructors
Instances3FromJSON, ToJSON, Show
(ReportSchemaErrors m, FromJSON m a) => FromJSON m (UninterpretedSignatures a)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Signed(Monad m, ToJSON m a) => ToJSON m (UninterpretedSignatures a)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SignedShow a => Show (UninterpretedSignatures a)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Signed
Constructors
SnapshotsnapshotVersion :: FileVersionsnapshotExpires :: FileExpiressnapshotInfoRoot :: FileInfoFile info for the root metadata
We list this explicitly in the snapshot so that we can check if we need to update the root metadata without first having to download the entire index tarball.
snapshotInfoMirrors :: FileInfoFile info for the mirror metadata
snapshotInfoTarGz :: FileInfoCompressed index tarball
snapshotInfoTar :: Maybe FileInfoUncompressed index tarball
Repositories are not required to provide this.
Instances5HasHeader, VerifyRole, ToJSON, FromJSON
HasHeader SnapshotDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SnapshotVerifyRole SnapshotDefined in hackage-security-0.6.4.0 · Hackage.Security.Trusted(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m SnapshotDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.SnapshotMonadReader RepoLayout m => ToJSON m SnapshotDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Snapshot(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Snapshot)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Snapshot
Delegation specification
NOTE: This is a close analogue of RoleSpec.
Constructors
Instances3Show, FromJSON, ToJSON
Show DelegationSpecDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonadKeys m => FromJSON m DelegationSpecDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonad m => ToJSON m DelegationSpecDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Targets
Delegations
Much like the Root datatype, this must have an invariant that ALL used keys (apart from the global keys, which are in the root key environment) must be listed in delegationsKeys.
Constructors
Instances3Show, FromJSON, ToJSON
Show DelegationsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonadKeys m => FromJSON m DelegationsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonad m => ToJSON m DelegationsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Targets
Target metadata
Most target files do not need expiry dates because they are not subject to change (and hence attacks like freeze attacks are not a concern).
Constructors
Instances5Show, HasHeader, ToJSON, FromJSON
Show TargetsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsHasHeader TargetsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonadKeys m => FromJSON m TargetsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonad m => ToJSON m TargetsDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TargetsMonadKeys m => FromJSON m (Signed Targets)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Targets
Constructors
Instances5HasHeader, VerifyRole, ToJSON, FromJSON
HasHeader TimestampDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TimestampVerifyRole TimestampDefined in hackage-security-0.6.4.0 · Hackage.Security.Trusted(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m TimestampDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.TimestampMonadReader RepoLayout m => ToJSON m TimestampDefined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Timestamp(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Timestamp)Defined in hackage-security-0.6.4.0 · Hackage.Security.TUF.Timestamp
54-bit integer values
JavaScript can only safely represent numbers between -(2^53 - 1) and
2^53 - 1.
TODO: Although we introduce the type here, we don't actually do any bounds checking and just inherit all type class instance from Int64. We should probably define fromInteger to do bounds checking, give different instances for type classes such as Bounded and FiniteBits, etc.
Instances17Bounded, Enum, Eq, Integral, Data, Num, …
Bounded Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalEnum Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalEq Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalIntegral Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalData Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalNum Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalOrd Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalRead Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalReal Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalShow Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalIx Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalBits Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalFiniteBits Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalStorable Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalPrintfArg Int54Defined in hackage-security-0.6.4.0 · Text.JSON.CanonicalReportSchemaErrors m => FromJSON m Int54Defined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSONMonad m => ToJSON m Int54Defined in hackage-security-0.6.4.0 · Hackage.Security.Util.JSON