Running 'test.R' [173s]
Running the tests in 'tests/test.R' failed.
Complete output:
  > ## simple test suite - avoid testthat! It has an insane amount of
  > ## unnecessary dependencies. A test package should have exactly 0
  > 
  > assert <- function(msg, what) {
  +     cat("   . ", msg,"\n")
  +     stopifnot(what)
  +     .GlobalEnv$ok <- .GlobalEnv$ok + 1L
  + }
  > 
  > xfail <- function(...) suppressWarnings(tryCatch({ ...; FALSE }, error=function(e) TRUE))
  > 
  > ## none of these are fatal
  > info <- function(...) message(" -- ", ...)
  > err  <- function(...) message(" ** ERROR: ", ...)
  > warn <- function(...) message(" !! ", ...)
  > 
  > ## all warnings (unless suppressed) are errors
  > options(warn=2)
  > 
  > library(PKI)
  Loading required package: base64enc
  > 
  > .GlobalEnv$ok <- 0L
  > 
  > ## Majority of tests are in th3 examples,
  > ## so we won't repeat those, but some special cases
  > ## not covered there as well as expected failures
  > 
  > info("Checking failure paths")
   -- Checking failure paths
  > xfail(PKI.load.cert(what="foo", file="bar")) ## set both what and file
  [1] TRUE
  > xfail(PKI.load.cert("foo", "DER")) ## binary format with text
  [1] TRUE
  > xfail(PKI.load.cert("nothing")) ## invalid content
  [1] TRUE
  > xfail(PKI.digest("foo", "bar")) ## invalid hash spec
  [1] TRUE
  > xfail(PKI.load.key(what="foo", file="bar"))
  [1] TRUE
  > xfail(PKI:::PKI.decode.SSH2(fn.priv.der)) ## try to load invalid content
  [1] TRUE
  > 
  > info("Checking key paths via files/connections")
   -- Checking key paths via files/connections
  > key <- PKI.genRSAkey(bits = 2048L)
  > fn.priv.pem <- tempfile()
  > PKI.save.key(key, target=fn.priv.pem)
   [1] "-----BEGIN RSA PRIVATE KEY-----"                                 
   [2] "MIIEogIBAAKCAQEAt7namnA0obMm5mxToI5CGrdBli3c919h9wI+vZpcOR27ByHc"
   [3] "20b3blEwW4SXiaRZEQWXreY2fgicwbmVAxX+WYnHyjtbZdGeZqWRFIyxM5oZ1cIJ"
   [4] "VkqOyo9p8epw1cCMRPMHD4vPfPI8F3HvNF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pjbxtDDXa3LuO4VupwWtkm0e"
  [20] "7L8iwmJnLL9/FbiC5GQ3nzVcg9+nS5+Zu2oAX/bDCuHdvPwlGaH2hZWhBgxGGyij"
  [21] "1p6mXXKgVW9guwaRCYCQPQKBgHlfoP1RM6A/HCIyTSDgKDZLJaw8DgCIfCV4fJ6I"
  [22] "xAHt6b0Oa8HKcm92v1lIKUySbli4XOCOAhmoRHOzqMYPnjxARjVktRqJ3KP73KfF"
  [23] "ukYbg518MZIZSabXPXERHN/6qi20SWFOeaNBLI48iB4Tcjl8HX/pFYG1FxdxW8g6"
  [24] "fzTfAoGAHyAyQ/3fUnf/K9m+3TMk+05USGDGM7WuIdl8UknZWMSGF9a53uCbVKtl"
  [25] "nEAIcLe1sNJ2vru+DF6OuG4FSxzySUNcrLY9kOlkliE/WlspTjU6QGSdukX2F/LM"
  [26] "LSJPXM3pnkyAbAQ+RVA6Lv+JQAbgGmQ6J9RY162eawUj+1+EzQE="            
  [27] "-----END RSA PRIVATE KEY-----"                                   
  > fn.priv.der <- tempfile()
  > PKI.save.key(key, "DER", target=fn.priv.der)
     [1] 30 82 04 a2 02 01 00 02 82 01 01 00 b7 b9 da 9a 70 34 a1 b3 26 e6 6c 53
    [25] a0 8e 42 1a b7 41 96 2d dc f7 5f 61 f7 02 3e bd 9a 5c 39 1d bb 07 21 dc
    [49] db 46 f7 6e 51 30 5b 84 97 89 a4 59 11 05 97 ad e6 36 7e 08 9c c1 b9 95
    [73] 03 15 fe 59 89 c7 ca 3b 5b 65 d1 9e 66 a5 91 14 8c b1 33 9a 19 d5 c2 09
    [97] 56 4a 8e ca 8f 69 f1 ea 70 d5 c0 8c 44 f3 07 0f 8b cf 7c f2 3c 17 71 ef
   [121] 34 5c 0c 5c d2 d4 70 9a e8 42 87 c4 b7 3b 43 fe 38 cd 76 96 f5 9f 58 43
   [145] d6 98 0b a5 ed 60 ac 82 f7 b2 0c 85 22 c4 fd cf 82 df 00 44 56 fc b8 c5
   [169] 50 90 24 7e 14 d0 5a 84 71 0c e5 41 ec e5 17 f5 a2 36 4e 16 9a e1 0a 01
   [193] 61 0e 9c 7b 4f 0a 55 6e f9 4c 2c 88 34 79 b9 ea 53 78 a9 0d e4 45 a4 f2
   [217] 81 11 2a 25 92 5d 8d 19 d9 df ad a7 3e c2 8d 01 90 c2 fd 46 01 30 93 45
   [241] 42 e3 c3 ab 3e 1e dd 2e dc af a5 bd 54 fa ff 63 b7 03 0c f7 a5 4d 0e 0e
   [265] f9 f1 f0 15 02 03 01 00 01 02 82 01 00 20 29 74 47 a1 c9 cc de b0 3a 19
   [289] 0f 80 a5 36 94 37 ad 4f 0d 63 47 98 96 6d 27 a2 f5 0c ff 04 ee 9b ed 71
   [313] 33 98 dd 30 f6 4a 57 25 46 2e 42 e5 96 c3 e0 8f 3f 5d 73 ff 97 21 5d d6
   [337] 4f 6c 15 5f 0b ac 8f 61 6b 07 a2 68 d2 0a 55 04 73 2c f7 de 39 25 39 a2
   [361] b8 80 b7 17 8d 05 12 fe 4a d4 8a ce a4 9f 73 4d b2 9e 7e 69 78 7c 25 7c
   [385] 87 eb ca 0b 4d fa 88 3e d8 17 3d 82 47 e0 ed 8a 87 07 c9 8b ef 30 3a 5d
   [409] a7 e7 e9 a3 06 ae 9d 8c 73 ba 9f 16 89 de a9 59 fc f3 b7 b5 22 cb 01 4a
   [433] 99 f5 94 62 22 b1 09 eb 0c de a0 81 4b fb 89 83 a7 13 61 1e 84 d3 68 a5
   [457] 35 75 bb ad f3 1a 83 ed 2d 03 c6 bd 24 99 c1 31 38 a7 62 09 53 d8 3c 00
   [481] f0 e3 f7 34 46 f8 4d 7e 7e cf c5 c6 b9 7e e2 8c f1 cf bb d8 a1 b2 4c c8
   [505] 6a c3 a2 3c 2b ab 2d 0d 8f 18 85 7e c8 55 9b 39 25 82 b6 97 2e e0 34 18
   [529] 38 15 1c 77 a7 02 81 81 00 e2 9f 98 21 0a d0 89 b5 11 cb 23 c7 d9 58 22
   [553] 06 4d 72 b0 6d 4b b0 8d 7e a4 d0 f1 1e ae 9f c1 38 c3 f9 1f 05 be 16 b2
   [577] 5b 2e 7d 03 34 76 3f ce 0a 6e d0 13 bd b3 7f 27 a9 3e 30 39 68 dc e5 7c
   [601] 88 5d 42 7b d9 3a 86 22 07 e5 73 49 45 5d d4 ef 63 2c 09 fd 42 1b 2d a6
   [625] ce d5 be 27 38 36 67 26 10 c2 32 46 a5 8b 63 f4 06 07 6d 22 89 42 d0 c9
   [649] 2e 71 f7 1d 53 df f8 1a 44 b1 9b 1b 15 23 69 8a 37 02 81 81 00 cf 8a b9
   [673] e4 9d aa 80 1d 78 ce 16 88 1b 49 80 14 6f 40 53 28 01 19 6e 7c e7 60 9e
   [697] 1b 7c f7 c4 dc 41 aa 24 fe e9 a5 41 73 53 be 9f 61 35 6b 76 65 da c9 8d
   [721] c6 90 39 a7 6f 20 14 ae 18 18 e7 3d d7 e6 87 29 51 67 9c a8 57 5a 08 d5
   [745] 9a 87 97 66 69 cc 9d 9a e1 a8 58 83 65 b6 6f 74 34 61 12 62 9d 7d 0f 93
   [769] ab dd a2 61 56 4d 84 4a c5 6b 5a c1 28 fa ec 6f b2 3c 25 72 d1 22 6b f9
   [793] 32 99 19 c2 13 02 81 80 55 2e dc 05 ff 84 a7 5e 72 53 c3 1d 49 ab 01 0f
   [817] 11 69 7c bb 78 69 e2 a5 a9 da 07 e8 1a 87 5e 1f b2 3a 1f d9 0e bc 85 4a
   [841] 14 cd 54 b9 11 81 a6 36 f1 b4 30 d7 6b 72 ee 3b 85 6e a7 05 ad 92 6d 1e
   [865] ec bf 22 c2 62 67 2c bf 7f 15 b8 82 e4 64 37 9f 35 5c 83 df a7 4b 9f 99
   [889] bb 6a 00 5f f6 c3 0a e1 dd bc fc 25 19 a1 f6 85 95 a1 06 0c 46 1b 28 a3
   [913] d6 9e a6 5d 72 a0 55 6f 60 bb 06 91 09 80 90 3d 02 81 80 79 5f a0 fd 51
   [937] 33 a0 3f 1c 22 32 4d 20 e0 28 36 4b 25 ac 3c 0e 00 88 7c 25 78 7c 9e 88
   [961] c4 01 ed e9 bd 0e 6b c1 ca 72 6f 76 bf 59 48 29 4c 92 6e 58 b8 5c e0 8e
   [985] 02 19 a8 44 73 b3 a8 c6 0f 9e 3c 40 46 35 64 b5 1a 89 dc a3 fb dc a7 c5
  [1009] ba 46 1b 83 9d 7c 31 92 19 49 a6 d7 3d 71 11 1c df fa aa 2d b4 49 61 4e
  [1033] 79 a3 41 2c 8e 3c 88 1e 13 72 39 7c 1d 7f e9 15 81 b5 17 17 71 5b c8 3a
  [1057] 7f 34 df 02 81 80 1f 20 32 43 fd df 52 77 ff 2b d9 be dd 33 24 fb 4e 54
  [1081] 48 60 c6 33 b5 ae 21 d9 7c 52 49 d9 58 c4 86 17 d6 b9 de e0 9b 54 ab 65
  [1105] 9c 40 08 70 b7 b5 b0 d2 76 be bb be 0c 5e 8e b8 6e 05 4b 1c f2 49 43 5c
  [1129] ac b6 3d 90 e9 64 96 21 3f 5a 5b 29 4e 35 3a 40 64 9d ba 45 f6 17 f2 cc
  [1153] 2d 22 4f 5c cd e9 9e 4c 80 6c 04 3e 45 50 3a 2e ff 89 40 06 e0 1a 64 3a
  [1177] 27 d4 58 d7 ad 9e 6b 05 23 fb 5f 84 cd 01
  attr(,"class")
  [1] "private.key.DER"
  > PKI.load.key(file=fn.priv.pem)
  <pointer: 0x000001d9f0b83a40>
  attr(,"class")
  [1] "private.key"
  > PKI.load.key(file=fn.priv.der, format="DER", private=TRUE)
  <pointer: 0x000001d9f0b83f40>
  attr(,"class")
  [1] "private.key"
  > fn.pub.pem <- tempfile()
  > PKI.save.key(key, target=fn.pub.pem, private=FALSE)
  [1] "-----BEGIN PUBLIC KEY-----"                                      
  [2] "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt7namnA0obMm5mxToI5C"
  [3] "GrdBli3c919h9wI+vZpcOR27ByHc20b3blEwW4SXiaRZEQWXreY2fgicwbmVAxX+"
  [4] "WYnHyjtbZdGeZqWRFIyxM5oZ1cIJVkqOyo9p8epw1cCMRPMHD4vPfPI8F3HvNFwM"
  [5] "XNLUcJroQofEtztD/jjNdpb1n1hD1pgLpe1grIL3sgyFIsT9z4LfAERW/LjFUJAk"
  [6] "fhTQWoRxDOVB7OUX9aI2Thaa4QoBYQ6ce08KVW75TCyINHm56lN4qQ3kRaTygREq"
  [7] "JZJdjRnZ362nPsKNAZDC/UYBMJNFQuPDqz4e3S7cr6W9VPr/Y7cDDPelTQ4O+fHw"
  [8] "FQIDAQAB"                                                        
  [9] "-----END PUBLIC KEY-----"                                        
  > fn.pub.der <- tempfile()
  > PKI.save.key(key, "DER", target=fn.pub.der, private=FALSE)
    [1] 30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 82 01 0f 00 30
   [26] 82 01 0a 02 82 01 01 00 b7 b9 da 9a 70 34 a1 b3 26 e6 6c 53 a0 8e 42 1a b7
   [51] 41 96 2d dc f7 5f 61 f7 02 3e bd 9a 5c 39 1d bb 07 21 dc db 46 f7 6e 51 30
   [76] 5b 84 97 89 a4 59 11 05 97 ad e6 36 7e 08 9c c1 b9 95 03 15 fe 59 89 c7 ca
  [101] 3b 5b 65 d1 9e 66 a5 91 14 8c b1 33 9a 19 d5 c2 09 56 4a 8e ca 8f 69 f1 ea
  [126] 70 d5 c0 8c 44 f3 07 0f 8b cf 7c f2 3c 17 71 ef 34 5c 0c 5c d2 d4 70 9a e8
  [151] 42 87 c4 b7 3b 43 fe 38 cd 76 96 f5 9f 58 43 d6 98 0b a5 ed 60 ac 82 f7 b2
  [176] 0c 85 22 c4 fd cf 82 df 00 44 56 fc b8 c5 50 90 24 7e 14 d0 5a 84 71 0c e5
  [201] 41 ec e5 17 f5 a2 36 4e 16 9a e1 0a 01 61 0e 9c 7b 4f 0a 55 6e f9 4c 2c 88
  [226] 34 79 b9 ea 53 78 a9 0d e4 45 a4 f2 81 11 2a 25 92 5d 8d 19 d9 df ad a7 3e
  [251] c2 8d 01 90 c2 fd 46 01 30 93 45 42 e3 c3 ab 3e 1e dd 2e dc af a5 bd 54 fa
  [276] ff 63 b7 03 0c f7 a5 4d 0e 0e f9 f1 f0 15 02 03 01 00 01
  attr(,"class")
  [1] "public.key.DER"
  > PKI.load.key(file=fn.pub.pem)
  <pointer: 0x000001d9f0b834a0>
  attr(,"class")
  [1] "public.key"
  > PKI.load.key(file=fn.pub.der, format="DER", private=FALSE)
  <pointer: 0x000001d9f0b83220>
  attr(,"class")
  [1] "public.key"
  > 
  > info("gmp")
   -- gmp
  > if (requireNamespace("gmp", quietly=TRUE)) {
  +     PKI.mkRSApubkey(gmp::as.bigz("119445732379544598056145200053932732877863846799652384989588303737527328743970559883211146487286317168142202446955508902936035124709397221178664495721428029984726868375359168203283442617134197706515425366188396513684446494070223079865755643116690165578452542158755074958452695530623055205290232290667934914919"))
  + } else {
  +     warn("gmp not found, skipping bignum tests")
  + }
   !! gmp not found, skipping bignum tests
  > 
  > info("Ciphers")
   -- Ciphers
  > skey <- PKI.random(256)
  > for (cipher in c("aes256ecb", "aes256ofb", "bfcbc", "bfecb", "bfofb", "bfcfb"))
  +     assert(cipher, all(PKI.decrypt(PKI.encrypt(charToRaw("foo!"), skey, cipher), skey, cipher)[1:4] == charToRaw("foo!")))
     .  aes256ecb 
     .  aes256ofb 
     .  bfcbc 
     .  bfecb 
     .  bfofb 
     .  bfcfb 
  > iv <- PKI.random(256)
  > for (cipher in c("bfcbc", "bfecb", "bfofb", "bfcfb"))
  +     assert(paste0(cipher, " (with IV)"),
  +                   all(PKI.decrypt(PKI.encrypt(charToRaw("foo!"), skey, cipher, iv=iv), skey, cipher, iv=iv)[1:4] == charToRaw("foo!")))
     .  bfcbc (with IV) 
     .  bfecb (with IV) 
     .  bfofb (with IV) 
     .  bfcfb (with IV) 
  > 
  > info("ASN.1")
   -- ASN.1
  > 
  > assert("ASN.1 encode/decode", 
  + { d <- ASN1.decode(ASN1.encode(ASN1.item(0:255, 3L)))
  +   ASN1.type(d) == 3L && all(d == as.raw(0:255)) })
     .  ASN.1 encode/decode 
  > 
  > info("Tar ball signing")
   -- Tar ball signing
  > tmpfn <- c(fn.pub.der, fn.pub.pem, fn.priv.der, fn.priv.pem)
  > fn <- tempfile()
  > ## on some systems using abs paths can break 100 byte limit
  > ## so we must do this in the tempdir
  > wd <- getwd()
  > td <- tempdir()
  > setwd(td)
  > tar(fn, basename(tmpfn), "none")
  > PKI.sign.tar(fn, key)
  > PKI.verify.tar(fn, key)
  [1] TRUE
  > setwd(wd)
  > 
  > unlink(c(fn, tmpfn))
  > 
  > proc.time()
     user  system elapsed 
     0.34    0.06    0.46