mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-05 12:05:58 +01:00
Add timestamps and certificate information for some test vectors
This commit is contained in:
parent
ba133cfc7d
commit
1de2e253d8
18 changed files with 252 additions and 3 deletions
|
@ -4,7 +4,11 @@
|
|||
|
||||
package org.sequoia_pgp.wot.vectors
|
||||
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.pgpainless.PGPainless
|
||||
import org.pgpainless.key.OpenPgpFingerprint
|
||||
import org.pgpainless.util.DateUtil
|
||||
import org.pgpainless.wot.network.ReferenceTime
|
||||
|
||||
class ExampleTest {
|
||||
|
@ -12,7 +16,16 @@ class ExampleTest {
|
|||
@Test
|
||||
fun test() {
|
||||
val vectors = BestViaRootVectors()
|
||||
val network = vectors.getNetworkAt(ReferenceTime.now())
|
||||
val network = vectors.getNetworkAt(vectors.t1)
|
||||
println(network)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun exp() {
|
||||
val vectors = CertExpiredVectors()
|
||||
val keys = PGPainless.readKeyRing().publicKeyRingCollection(vectors.keyRingInputStream())
|
||||
val bob = keys.getPublicKeyRing(OpenPgpFingerprint.parse(vectors.bobFpr.toString()).keyId)
|
||||
val info = PGPainless.inspectKeyRing(bob, vectors.t1.timestamp)
|
||||
println(DateUtil.formatUTCDate(info.primaryKeyExpirationDate))
|
||||
}
|
||||
}
|
|
@ -11,9 +11,31 @@ import org.pgpainless.wot.WebOfTrust
|
|||
import org.pgpainless.wot.network.Network
|
||||
import org.pgpainless.wot.network.ReferenceTime
|
||||
import java.io.InputStream
|
||||
import java.lang.IllegalArgumentException
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
interface ArtifactVectors {
|
||||
|
||||
private fun parseDate(string: String): Date {
|
||||
return try {
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss z")
|
||||
.apply { timeZone = TimeZone.getTimeZone("UTC") }
|
||||
.parse(string)
|
||||
} catch (e: ParseException) {
|
||||
SimpleDateFormat("yyyy-MM-dd")
|
||||
.apply {timeZone = TimeZone.getTimeZone("UTC") }
|
||||
.parse(string)
|
||||
} catch (e: ParseException) {
|
||||
throw IllegalArgumentException(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun parseReferenceTime(string: String): ReferenceTime {
|
||||
return ReferenceTime.timestamp(parseDate(string))
|
||||
}
|
||||
|
||||
fun getResourceName(): String
|
||||
|
||||
fun getNetworkAt(referenceTime: ReferenceTime, policy: Policy = PGPainless.getPolicy()): Network {
|
||||
|
|
|
@ -19,6 +19,10 @@ import org.pgpainless.wot.network.Fingerprint
|
|||
*
|
||||
* When the root is B, then the path that we find for A should be `A -> B
|
||||
* -> C -> Target`, not `A -> Y -> Z -> Target`.
|
||||
*
|
||||
* Timeline:
|
||||
* - t0: keys are generated.
|
||||
* - t1: third-party certifications are issued.
|
||||
*/
|
||||
class BestViaRootVectors: ArtifactVectors {
|
||||
|
||||
|
@ -46,6 +50,16 @@ class BestViaRootVectors: ArtifactVectors {
|
|||
val zebra_uid = "<zebra@example.org>"
|
||||
// Certified by: 86CB4639D1FE096BA941D05822B8AF50198C49DD
|
||||
|
||||
/**
|
||||
* Create A, B, C, Y, Z, Target.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2021-09-27 12:51:50 UTC")
|
||||
|
||||
/**
|
||||
* Create certifications.
|
||||
*/
|
||||
val t1 = parseReferenceTime("2021-09-27 12:52:50 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/best-via-root.pgp"
|
||||
}
|
||||
|
|
|
@ -43,6 +43,26 @@ class CertExpiredVectors: ArtifactVectors {
|
|||
val carolUid = "<carol@example.org>"
|
||||
// Certified by: B166B31AE5F95600B3F7184FE74C6CE62821686F
|
||||
|
||||
/**
|
||||
* Create A, B, C.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2020-01-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* Create certifications (amount = 60).
|
||||
*/
|
||||
val t1 = parseReferenceTime("2020-02-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* B expires.
|
||||
*/
|
||||
val t2 = parseReferenceTime("2020-02-15 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* Create certifications (amount = 120).
|
||||
*/
|
||||
val t3 = parseReferenceTime("2020-04-01 00:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/cert-expired.pgp"
|
||||
}
|
||||
|
|
|
@ -28,6 +28,30 @@ class CertRevokedHardVectors: ArtifactVectors {
|
|||
// Certified by: BF680710128E6BCCB2268154569F5F6BFB95C544
|
||||
// Certified by: 90E02BFB03FAA04714D1D3D87543157EF3B12BE9
|
||||
|
||||
/**
|
||||
* A, B, C, D are generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2020-01-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A certifies B - 2/120.
|
||||
* B certifies D - 1/60.
|
||||
* A certifies C - 2/30.
|
||||
* C certifies D - 1/120.
|
||||
*/
|
||||
val t1 = parseReferenceTime("2020-02-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* B is hard revoked.
|
||||
*/
|
||||
val t2 = parseReferenceTime("2020-03-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A certifies B (amount = 120).
|
||||
* B certifies D (amount = 120).
|
||||
*/
|
||||
val t3 = parseReferenceTime("2020-04-01 00:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/cert-revoked-hard.pgp"
|
||||
}
|
||||
|
|
|
@ -122,6 +122,32 @@ class CertRevokedSoftVectors: ArtifactVectors {
|
|||
// Certified by: AB4E3F8EE8BBD3459754D75ACE570F9B8C7DC75D
|
||||
// Certified by: 4CD8737F76C2B897C4F058DBF28C47540FA2C3B3
|
||||
|
||||
|
||||
/**
|
||||
* A, B, C, D are generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2020-01-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A certifies B - 2/120.
|
||||
* B certifies D - 1/60.
|
||||
* A certifies C - 2/30.
|
||||
* C certifies D - 1/120.
|
||||
*/
|
||||
val t1 = parseReferenceTime("2020-02-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* B is soft revoked.
|
||||
*/
|
||||
val t2 = parseReferenceTime("2020-03-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A certifies B (amount = 120).
|
||||
* B certifies D (amount = 120).
|
||||
*/
|
||||
val t3 = parseReferenceTime("2020-04-01 00:00:00 UTC")
|
||||
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/cert-revoked-soft.pgp"
|
||||
}
|
||||
|
|
|
@ -75,6 +75,26 @@ class CertificationLivenessVectors: ArtifactVectors {
|
|||
// Certified by: 840891562819D3A108C4DA1BB31438DE34F8CF69
|
||||
// Certified by: 840891562819D3A108C4DA1BB31438DE34F8CF69
|
||||
|
||||
/**
|
||||
* Create A, B, C.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2020-01-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A certifies B (2/60), B certifies C (1/60).
|
||||
*/
|
||||
val t1 = parseReferenceTime("2020-02-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A certifies B (2/120, expires at t3), B certifies C (1/120).
|
||||
*/
|
||||
val t2 = parseReferenceTime("2020-03-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A's certification of B at t2 expires.
|
||||
*/
|
||||
val t3 = parseReferenceTime("2020-04-01 00:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/certification-liveness.pgp"
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
package org.sequoia_pgp.wot.vectors
|
||||
|
||||
import org.pgpainless.wot.network.Fingerprint
|
||||
|
||||
/**
|
||||
* Four certificates that only make certifications (depth is always 0).
|
||||
*
|
||||
|
@ -22,7 +24,22 @@ package org.sequoia_pgp.wot.vectors
|
|||
*/
|
||||
class CertificationNetworkVectors: ArtifactVectors {
|
||||
|
||||
// TODO: Extract Fingerprints, UIDs and timestamps
|
||||
val aliceFpr = Fingerprint("B2B371214EF71AFD16E42C62D81360B4C0489225")
|
||||
val aliceUid = "<alice@example.org>"
|
||||
|
||||
val bobFpr = Fingerprint("A68DF00EB82F9C49C27CC7723C5F5BBE6B790C05")
|
||||
val bobUid = "<bob@example.org>"
|
||||
|
||||
val carolFpr = Fingerprint("AB9EF1C89631519842ED559697557DD147D99C97")
|
||||
val carolUid = "<carol@example.org>"
|
||||
|
||||
val daveFpr = Fingerprint("9A1AE937B5CB8BC46048AB63023CC01973ED9DF3")
|
||||
val daveUid = "<dave@example.org>"
|
||||
|
||||
/**
|
||||
* A few minutes after the Network has been generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2023-01-19 12:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/certification-network.pgp"
|
||||
|
|
|
@ -56,6 +56,27 @@ class CertificationRevokedVectors: ArtifactVectors {
|
|||
val carolUid = "<carol@example.org>"
|
||||
// Certified by: 4258ACF6C3C8FCE130D6EBAB0CC5158AEA25F24A
|
||||
|
||||
/**
|
||||
* A, B, C are created.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2020-01-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A certifies B, B certifies C.
|
||||
*/
|
||||
val t1 = parseReferenceTime("2020-02-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A revokes their certification of B.
|
||||
* A should now no longer be able to authenticate B or C.
|
||||
*/
|
||||
val t2 = parseReferenceTime("2020-03-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A re-certifies B.
|
||||
*/
|
||||
val t3 = parseReferenceTime("2020-04-01 00:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/certification-revoked.pgp"
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@ package org.sequoia_pgp.wot.vectors
|
|||
|
||||
class CliquesLocalOptima2Vectors: CliquesVectors() {
|
||||
|
||||
/**
|
||||
* A few minutes after the network is fully generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2021-02-14 00:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/cliques-local-optima-2.pgp"
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@ package org.sequoia_pgp.wot.vectors
|
|||
|
||||
class CliquesLocalOptimaVectors: CliquesVectors() {
|
||||
|
||||
/**
|
||||
* A few minutes after the network is fully generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2021-02-14 00:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/cliques-local-optima.pgp"
|
||||
}
|
||||
|
|
|
@ -105,6 +105,11 @@ open class CliquesVectors: ArtifactVectors {
|
|||
val targetFpr = Fingerprint("CE22ECD282F219AA99598BA3B58A7DA61CA97F55")
|
||||
val targetUid = "<target@example.org>"
|
||||
|
||||
/**
|
||||
* A few minutes after the network is fully generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2021-02-14 00:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/cliques.pgp"
|
||||
}
|
||||
|
|
|
@ -49,6 +49,11 @@ class CycleVectors: ArtifactVectors {
|
|||
val frankUid = "<frank@example.org>"
|
||||
// Certified by: 78C3814EFD16E68F4F1AB4B874E30AE11FFCFB1B
|
||||
|
||||
/**
|
||||
* A few minutes after the network has been generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2021-10-01 12:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/cycle.pgp"
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
package org.sequoia_pgp.wot.vectors
|
||||
|
||||
import org.pgpainless.wot.network.Fingerprint
|
||||
|
||||
/**
|
||||
* How gpg interprets ownertrust is a bit complicated. For a certificate
|
||||
* that is marked as "fully trusted" or "partially trusted" to be
|
||||
|
@ -28,7 +30,33 @@ package org.sequoia_pgp.wot.vectors
|
|||
*/
|
||||
class GpgTrustrootsVectors: ArtifactVectors {
|
||||
|
||||
// TODO: Extract fingerprints and UIDs
|
||||
val rootFpr = Fingerprint("D8330354E99DB503729A68D4AAE7E9EC2129CEC3")
|
||||
val rootUid = "<root@example.org>"
|
||||
|
||||
val a1Fpr = Fingerprint("80666EDD21A008D467243E47444D4C0F515D269A")
|
||||
val a1Uid = "<a1@example.org>"
|
||||
|
||||
val a2Fpr = Fingerprint("A6D2F50B1C9544A717B7625395FD89DA7093B735")
|
||||
val a2Uid = "<a2@example.org>"
|
||||
|
||||
val a3Fpr = Fingerprint("AFDD8AECD999F5CDC7027B23EECC4F0EA03A5F35")
|
||||
val a3Uid = "<a3@example.org>"
|
||||
|
||||
val dFpr = Fingerprint("BB0333A98A05430FF6A784A706D474BF36A3D4F9")
|
||||
val dUid = "<d@example.org>"
|
||||
|
||||
val targetFpr = Fingerprint("30A185EA9319FF1D0BCBDBFCF2CD31DCC3DCAA02")
|
||||
val targetUid = "<target@example.org>"
|
||||
|
||||
/**
|
||||
* Certificates are generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2020-01-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* Certifications are made.
|
||||
*/
|
||||
val t1 = parseReferenceTime("2020-02-01 00:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/gpg-trustroots.pgp"
|
||||
|
|
|
@ -280,6 +280,11 @@ class InfinityAndBeyondVectors: ArtifactVectors {
|
|||
Fingerprint("B69A678AA242FA4F0BBF12205C0608799B0E3C51"),
|
||||
)
|
||||
|
||||
/**
|
||||
* A few minutes after the network has been generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2022-01-28 15:18:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/infinity-and-beyond.pgp"
|
||||
}
|
||||
|
|
|
@ -18,6 +18,15 @@ class IsolatedRootVectors: ArtifactVectors {
|
|||
val aliceUid = "<alice@example.org>"
|
||||
val aliceOtherOrguid = "<alice@other.org>"
|
||||
|
||||
/**
|
||||
* A is created.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2020-01-01 00:00:00 UTC")
|
||||
|
||||
/**
|
||||
* A's UserID is revoked.
|
||||
*/
|
||||
val t1 = parseReferenceTime("2020-02-01 00:00:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/isolated-root.pgp"
|
||||
|
|
|
@ -78,6 +78,11 @@ class LocalOptimaVectors: ArtifactVectors {
|
|||
val henryUid = "<henry@example.org>"
|
||||
// Certified by: 70507A9058A57FEAE18CC3CE6A398AC9051D9CA8
|
||||
|
||||
/**
|
||||
* A few minutes after the network has been generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2021-10-01 10:27:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/local-optima.pgp"
|
||||
}
|
||||
|
|
|
@ -43,6 +43,11 @@ class MultipleCertifications1Vectors: ArtifactVectors {
|
|||
val dave_uid = "<dave@example.org>"
|
||||
// Certified by: 853304031E7B0B116BBD0B398734F11945313904
|
||||
|
||||
/**
|
||||
* A few moments after the network has been generated.
|
||||
*/
|
||||
val t0 = parseReferenceTime("2021-10-06 12:20:00 UTC")
|
||||
|
||||
override fun getResourceName(): String {
|
||||
return "org/sequoia_pgp/wot/vectors/multiple-certifications-1.pgp"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue