Running 'test.R'
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] "MIIEowIBAAKCAQEAyxqCZS1gDggwP0+y3XVkIj+6O75zcl532fTwoRGNFvGt1kAX"
   [3] "UpSjp7xADf6g+aF14O+aNeQfTWtiawMAiZ+9bLQNFnMdb5n03N8PbyiaeaAsgJbd"
   [4] "6FSG0ki0bN8EQ+EC/2rr3CpGTS8FrWAZP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3iPWih/tWPdpYaznzU1WRXS/qp9C"
  [20] "SNHNO+06rpU59L3jJNDe3clIqB9qHbKBe8aoSgf7ueA+nP3grrtlhUhr1XZhTWqh"
  [21] "EOmYOaMrxeLxDOJfAHZ1UQKBgQCNbux/fGcDlnvNpPGF5Lcehy7SUJAnNLbAyMBU"
  [22] "ee0b9C7ulu7qmWwlYhsKSR0SekOgWcIz4zmkSP7Oil6CGlCGUIz7jzLvJEDwpC2W"
  [23] "m1Q1Vdd+GqM04l5fjnUaVSfzJqQQzXY8seKXyOXvFXoudt7brtSmwCEOgNbAXRh9"
  [24] "jUuGMQKBgDJQYOOMgvBPbRYU7zmTd5UkWz4XSt9izcCB2HF6BUtivPTNBSlrjCqo"
  [25] "O4DgUfazZfI+WDRbXnoMvjiTSryPLZBNTetI/MK2ovPGWTCFupTWuFaZPq7gKCK0"
  [26] "fpemXu1Hennx7ZMhQly4jr1efWob2SJTcQluadWjWAIwB8dwuAeo"            
  [27] "-----END RSA PRIVATE KEY-----"                                   
  > fn.priv.der <- tempfile()
  > PKI.save.key(key, "DER", target=fn.priv.der)
     [1] 30 82 04 a3 02 01 00 02 82 01 01 00 cb 1a 82 65 2d 60 0e 08 30 3f 4f b2
    [25] dd 75 64 22 3f ba 3b be 73 72 5e 77 d9 f4 f0 a1 11 8d 16 f1 ad d6 40 17
    [49] 52 94 a3 a7 bc 40 0d fe a0 f9 a1 75 e0 ef 9a 35 e4 1f 4d 6b 62 6b 03 00
    [73] 89 9f bd 6c b4 0d 16 73 1d 6f 99 f4 dc df 0f 6f 28 9a 79 a0 2c 80 96 dd
    [97] e8 54 86 d2 48 b4 6c df 04 43 e1 02 ff 6a eb dc 2a 46 4d 2f 05 ad 60 19
   [121] 3d fc a4 98 bb 53 cc 5d 5b 99 7f bc da d7 f7 aa 8f 78 b6 98 e5 97 a0 55
   [145] 2e 81 3b 23 03 77 af 54 85 cc e1 07 c1 5d f9 b0 00 ea 51 16 49 74 4e 3e
   [169] b4 a7 3b df 39 f8 84 8b 95 7a d8 42 7a 59 29 6e 2d 01 80 73 8c 05 b3 44
   [193] 24 1b 8e 9f f2 c2 fe 4e 45 29 5b bb 6c c6 4c 59 ea 47 e7 fd aa f3 7a fc
   [217] 73 6e 2a 6d 34 30 19 a1 73 73 ac c9 b5 e2 de 0e af 4b 4a 0d 3f 46 e4 cf
   [241] 0c 2d 8a 30 f6 8b 5a 65 1d bc 92 3b 8e 90 aa f9 79 04 e1 a4 78 47 b4 56
   [265] 4f cc 8b c5 02 03 01 00 01 02 82 01 00 2c 3d 08 31 67 06 80 cf ee 48 60
   [289] 00 ee e5 42 ac 06 12 f7 af e6 3f ff 4d 1e 33 90 95 18 b8 51 4a cf 69 37
   [313] 19 0d 62 f4 59 94 f2 a3 c9 b6 40 e1 57 06 69 51 fe d2 83 31 ef 05 a7 16
   [337] e6 8f 53 74 a4 40 7c 88 4b 07 1a 97 9f 62 db 90 26 4f 63 04 42 6b e7 0f
   [361] 55 62 e5 44 5f 79 b8 18 ed a3 a5 70 55 a1 92 25 b1 15 21 2e 6f 23 4e ad
   [385] fb 99 89 95 c5 71 aa 11 3d b5 75 b4 01 cb ee 16 13 37 c0 5c 8f 02 3f b6
   [409] 0d 84 2c f9 bd 58 63 fb ad 82 20 31 27 fe f9 36 81 9d e0 42 f4 36 09 f8
   [433] fe f6 d4 1a 09 1c b8 ff 30 ca 5c d0 38 e6 4e 1e 4e 56 e4 fb 3a 0c 3b d4
   [457] eb cb 59 4f 99 80 bb d9 40 44 df 0e 41 ef 36 2c df 49 2e cd 3a d6 3a 8b
   [481] ff a3 1f d4 d9 6c 80 c7 03 70 4a 4a ce 37 c1 78 cd 10 84 c0 0e e9 8e d7
   [505] df 5f 1b bb 21 3d 30 73 63 14 7a 02 9d b4 e7 9d e2 7b 01 5d 72 f1 80 62
   [529] 30 7e 01 89 d1 02 81 81 00 e4 77 7d 2f 4b ad 01 a5 fa a9 59 1a bc f2 ad
   [553] 6b 1b c6 08 fa a6 7c 99 04 77 cb 20 ea 5b 32 de ad b2 2e a6 d3 57 69 82
   [577] 29 f1 ab ca 0c e6 c8 14 3f d0 4d ce 90 1b b8 b8 3a 8a b2 47 05 70 2f de
   [601] b2 50 e5 81 ce db 0f 4b d0 c4 b8 cb 98 ac 81 87 c5 34 73 26 81 cf cf 29
   [625] d4 23 71 36 be 49 6f 63 42 2f 90 cd f9 60 a1 c3 b0 cf c0 39 b3 f8 6f f5
   [649] 20 fc 4f d2 f2 cc cd f0 c0 61 09 eb f1 6c 7e a0 55 02 81 81 00 e3 94 87
   [673] ee 81 c8 fa 25 24 a6 b8 4b f2 2f a3 32 67 a7 cf df ef 41 0d b5 53 62 cb
   [697] 9e 56 9c 61 95 5a a5 b5 6d 24 d4 1d 08 00 c1 c5 2e 86 f2 2c 93 b9 75 f9
   [721] 9c 9c 64 3c bb e7 6e fd 52 9c d3 bc 4c 0f 88 80 73 57 50 34 18 24 49 60
   [745] b4 e0 35 00 c9 37 07 5c 6f 8d 16 36 e2 51 ad 60 60 5b 91 7e 33 59 3e 7d
   [769] 7b d1 5b 85 34 4c a8 3e c3 09 7d c9 51 f1 01 49 2f b6 2c d3 c0 86 48 06
   [793] 26 b7 8d ed b1 02 81 80 7a 47 09 95 3a a7 89 ee 4f ce 3b 86 78 02 5a 96
   [817] ac f2 bc f3 8a 0f bd c6 0a 67 89 62 65 15 40 e1 2e 30 91 d1 23 43 b1 0a
   [841] c9 f1 eb de 23 d6 8a 1f ed 58 f7 69 61 ac e7 cd 4d 56 45 74 bf aa 9f 42
   [865] 48 d1 cd 3b ed 3a ae 95 39 f4 bd e3 24 d0 de dd c9 48 a8 1f 6a 1d b2 81
   [889] 7b c6 a8 4a 07 fb b9 e0 3e 9c fd e0 ae bb 65 85 48 6b d5 76 61 4d 6a a1
   [913] 10 e9 98 39 a3 2b c5 e2 f1 0c e2 5f 00 76 75 51 02 81 81 00 8d 6e ec 7f
   [937] 7c 67 03 96 7b cd a4 f1 85 e4 b7 1e 87 2e d2 50 90 27 34 b6 c0 c8 c0 54
   [961] 79 ed 1b f4 2e ee 96 ee ea 99 6c 25 62 1b 0a 49 1d 12 7a 43 a0 59 c2 33
   [985] e3 39 a4 48 fe ce 8a 5e 82 1a 50 86 50 8c fb 8f 32 ef 24 40 f0 a4 2d 96
  [1009] 9b 54 35 55 d7 7e 1a a3 34 e2 5e 5f 8e 75 1a 55 27 f3 26 a4 10 cd 76 3c
  [1033] b1 e2 97 c8 e5 ef 15 7a 2e 76 de db ae d4 a6 c0 21 0e 80 d6 c0 5d 18 7d
  [1057] 8d 4b 86 31 02 81 80 32 50 60 e3 8c 82 f0 4f 6d 16 14 ef 39 93 77 95 24
  [1081] 5b 3e 17 4a df 62 cd c0 81 d8 71 7a 05 4b 62 bc f4 cd 05 29 6b 8c 2a a8
  [1105] 3b 80 e0 51 f6 b3 65 f2 3e 58 34 5b 5e 7a 0c be 38 93 4a bc 8f 2d 90 4d
  [1129] 4d eb 48 fc c2 b6 a2 f3 c6 59 30 85 ba 94 d6 b8 56 99 3e ae e0 28 22 b4
  [1153] 7e 97 a6 5e ed 47 7a 79 f1 ed 93 21 42 5c b8 8e bd 5e 7d 6a 1b d9 22 53
  [1177] 71 09 6e 69 d5 a3 58 02 30 07 c7 70 b8 07 a8
  attr(,"class")
  [1] "private.key.DER"
  > PKI.load.key(file=fn.priv.pem)
  <pointer: 0x0000028f66e3d2f0>
  attr(,"class")
  [1] "private.key"
  > PKI.load.key(file=fn.priv.der, format="DER", private=TRUE)
  <pointer: 0x0000028f66e3cc10>
  attr(,"class")
  [1] "private.key"
  > fn.pub.pem <- tempfile()
  > PKI.save.key(key, target=fn.pub.pem, private=FALSE)
  [1] "-----BEGIN PUBLIC KEY-----"                                      
  [2] "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyxqCZS1gDggwP0+y3XVk"
  [3] "Ij+6O75zcl532fTwoRGNFvGt1kAXUpSjp7xADf6g+aF14O+aNeQfTWtiawMAiZ+9"
  [4] "bLQNFnMdb5n03N8PbyiaeaAsgJbd6FSG0ki0bN8EQ+EC/2rr3CpGTS8FrWAZPfyk"
  [5] "mLtTzF1bmX+82tf3qo94tpjll6BVLoE7IwN3r1SFzOEHwV35sADqURZJdE4+tKc7"
  [6] "3zn4hIuVethCelkpbi0BgHOMBbNEJBuOn/LC/k5FKVu7bMZMWepH5/2q83r8c24q"
  [7] "bTQwGaFzc6zJteLeDq9LSg0/RuTPDC2KMPaLWmUdvJI7jpCq+XkE4aR4R7RWT8yL"
  [8] "xQIDAQAB"                                                        
  [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 cb 1a 82 65 2d 60 0e 08 30 3f 4f b2 dd 75 64 22 3f
   [51] ba 3b be 73 72 5e 77 d9 f4 f0 a1 11 8d 16 f1 ad d6 40 17 52 94 a3 a7 bc 40
   [76] 0d fe a0 f9 a1 75 e0 ef 9a 35 e4 1f 4d 6b 62 6b 03 00 89 9f bd 6c b4 0d 16
  [101] 73 1d 6f 99 f4 dc df 0f 6f 28 9a 79 a0 2c 80 96 dd e8 54 86 d2 48 b4 6c df
  [126] 04 43 e1 02 ff 6a eb dc 2a 46 4d 2f 05 ad 60 19 3d fc a4 98 bb 53 cc 5d 5b
  [151] 99 7f bc da d7 f7 aa 8f 78 b6 98 e5 97 a0 55 2e 81 3b 23 03 77 af 54 85 cc
  [176] e1 07 c1 5d f9 b0 00 ea 51 16 49 74 4e 3e b4 a7 3b df 39 f8 84 8b 95 7a d8
  [201] 42 7a 59 29 6e 2d 01 80 73 8c 05 b3 44 24 1b 8e 9f f2 c2 fe 4e 45 29 5b bb
  [226] 6c c6 4c 59 ea 47 e7 fd aa f3 7a fc 73 6e 2a 6d 34 30 19 a1 73 73 ac c9 b5
  [251] e2 de 0e af 4b 4a 0d 3f 46 e4 cf 0c 2d 8a 30 f6 8b 5a 65 1d bc 92 3b 8e 90
  [276] aa f9 79 04 e1 a4 78 47 b4 56 4f cc 8b c5 02 03 01 00 01
  attr(,"class")
  [1] "public.key.DER"
  > PKI.load.key(file=fn.pub.pem)
  <pointer: 0x0000028f66e3cdf0>
  attr(,"class")
  [1] "public.key"
  > PKI.load.key(file=fn.pub.der, format="DER", private=FALSE)
  <pointer: 0x0000028f66e3d430>
  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")
  + }
    [1] 30 81 9f 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 81 8d 00 30 81 89
   [26] 02 81 81 00 aa 18 ab a4 3b 50 de ef 38 59 8f af 87 d2 ab 63 4e 45 71 c1 30
   [51] a9 bc a7 b8 78 26 74 14 fa ab 8b 47 1b d8 96 5f 5c 9f c3 81 84 85 ea f5 29
   [76] c2 62 46 f3 05 50 64 a8 de 19 c8 c3 38 be 54 96 cb ae b0 59 dc 0b 35 81 43
  [101] b4 4a 35 44 9e b2 64 11 31 21 a4 55 bd 7f de 3f ac 91 9e 94 b5 6f b9 bb 4f
  [126] 65 1c db 23 ea d4 39 d6 cd 52 3e b0 81 91 e7 5b 35 fd 13 a7 41 9b 30 90 f2
  [151] 47 87 bd 4f 4e 19 67 02 03 01 00 01
  > 
  > 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 
  Error in PKI.encrypt(charToRaw("foo!"), skey, cipher) : 
    error:0308010C:digital envelope routines::unsupported
  Calls: assert -> stopifnot -> PKI.decrypt -> PKI.encrypt
  Execution halted