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] "MIIEowIBAAKCAQEAmkGbcC4F0Bp0aGV9EC23x2FdWUIKmUl0/bYjrlFjY3K83aEx"
   [3] "/37YwQbVkqvoTKRWWWawbeSp28pVTWSgXOpGp6XbSixm2dv7NPdte22YmuKAUMft"
   [4] "f4IyENknEYzP68E2xhelOHoh5pAvO+UgXS+EUKW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JIanzM3fUI6LYlDfe2QUVuoeLo"
  [20] "EKMF0zYFmQumOqlZvQ1uj9iVra6JZtHKR0cVFTIzMSr+KdfK1tY1GRGPnk7jbnSc"
  [21] "nM/SONGMCl19zBUhWGba4OECgYBxyQON9ksZg4YUztFw1+cydqPirzPilZ7x3QZQ"
  [22] "xVO8xyJgoTmeSoNFxqT1O2eDINyQtbXV2CC6WbolfOdUpv7yzah4CxOOovQNF6u3"
  [23] "OoVlfrkSo0bcYhWMvKlmISRS8Oszo5odUwbwKfc9Zxz56JPUsb2VL2bu2bYw6GdA"
  [24] "k0GeHQKBgCZ5letLHGF6rex844+xe47Hoxju2R7W7uOWHyi90uIDGde/PuuZhM8H"
  [25] "GnSRRo9S8KnXYJritSNkT+F895oyH7AHbnKBcp8QArbOBRMPA7Of61IjzL7pQcLS"
  [26] "D5hznwEgwU8dFS9O4HRKq4/+AEG0obBlWdheq6OtmJir3RC7Hyxs"            
  [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 9a 41 9b 70 2e 05 d0 1a 74 68 65 7d
    [25] 10 2d b7 c7 61 5d 59 42 0a 99 49 74 fd b6 23 ae 51 63 63 72 bc dd a1 31
    [49] ff 7e d8 c1 06 d5 92 ab e8 4c a4 56 59 66 b0 6d e4 a9 db ca 55 4d 64 a0
    [73] 5c ea 46 a7 a5 db 4a 2c 66 d9 db fb 34 f7 6d 7b 6d 98 9a e2 80 50 c7 ed
    [97] 7f 82 32 10 d9 27 11 8c cf eb c1 36 c6 17 a5 38 7a 21 e6 90 2f 3b e5 20
   [121] 5d 2f 84 50 a5 83 18 b7 0d 01 b4 92 ac b1 fa c6 92 6f 1f 67 41 29 6f b6
   [145] 23 76 46 9e d3 fd cc 1f b8 7e 25 e6 a6 98 04 a2 71 c3 e9 a9 b9 7e b7 86
   [169] be 32 f0 cf d0 3b 99 e2 a9 01 82 85 49 69 e9 e6 2b ac 22 0f 18 83 2b 37
   [193] fa 68 e1 88 b9 1a 50 fb b5 cf 09 7b de 71 7d 40 ac 08 e3 9b 41 b0 08 23
   [217] ed 55 4d 89 09 60 95 0b d8 0b eb b0 60 d4 3b 10 57 27 83 cf 65 67 77 64
   [241] a6 d6 6d 53 a2 07 ce e0 fa ba 18 3e d1 96 a9 2a 98 10 6e fe 17 48 41 be
   [265] fd 6b f6 91 02 03 01 00 01 02 82 01 00 14 80 8c ce cb a7 25 22 26 ff ab
   [289] 21 84 b1 76 e0 2e 9e 30 1b 59 7a 47 2b 9f ff 01 de 0c de 37 5d 0c 22 2e
   [313] e7 0c cc c8 b5 5b 19 ae cd 5f 6a 34 5b 6f b5 78 d4 9a 54 43 2c b0 ca c1
   [337] 09 99 5f df f5 2f 53 a6 97 a1 31 ea 8d 88 5c 2c 76 7f ba 0d 37 f6 93 06
   [361] 07 98 6f 6f 05 13 3f a0 93 05 1d 92 08 1c 2b 0f 60 22 c7 77 b4 09 3b 1e
   [385] 38 7f 7a 2d cd 64 3a 38 e2 37 7d d7 08 b9 a0 4c 32 f1 4a 88 b3 45 25 11
   [409] e1 b2 c9 66 f5 c0 6f 3f f7 e7 5d 2f 5b 05 b2 9f 7c c2 66 50 8a e2 14 7d
   [433] 5b ba 3d e1 f6 85 0d 3c a0 d1 3f 02 9a e2 c0 69 6d c1 cf f7 a2 e6 11 19
   [457] 54 2e a5 bc b8 45 e1 c0 c3 62 c8 5c 6f b5 b3 df 82 83 a8 17 79 52 41 5f
   [481] 15 6a c4 00 2f 3d 2f a3 10 d1 c4 3e 3c 12 c8 c6 9d 02 e9 9e 70 30 8d 8e
   [505] 3d 86 d0 70 bd 95 cc a7 33 de 30 75 00 d7 72 e6 1a df 97 c5 af 46 ca 77
   [529] 98 a2 d5 27 6b 02 81 81 00 d3 bf 5f a5 de 27 9c ec 46 da ea c9 50 ca e5
   [553] 61 39 44 c6 07 37 b6 2a 49 b4 67 42 59 85 03 c2 fb 46 01 27 07 08 22 88
   [577] 43 41 38 bb 55 6e e6 01 46 18 ce 8b 4b cc f9 df 6c c4 0d 39 59 db 31 be
   [601] a0 01 a5 a7 f5 ec f8 d0 94 cf 8a c4 82 74 aa 25 54 8b b9 9c f4 4b df 5b
   [625] 18 cd b9 90 ef ad 4e 11 20 34 bf dc b0 fb 6e e9 cc 91 45 5c a9 94 10 57
   [649] ed b6 a6 0c 83 c4 5a 57 af 3c 04 cf b8 1f 58 58 2f 02 81 81 00 ba 7e 6a
   [673] 17 64 8f 75 ce 23 02 73 8f e1 bd 22 a0 2b 93 6d 2d 8f de aa b1 8b 2b f5
   [697] 7c 78 56 fb 44 96 94 45 fa 63 77 4f 32 93 c1 6f bf 3d 5c cb e5 87 c7 cd
   [721] fb 9b 9a 8d 9b 90 98 92 76 80 ac a0 a1 85 05 66 cd e4 bc c7 9d 0c 19 34
   [745] 53 2a a7 dd ea 4c cf 5b a6 b9 98 1d e7 5a 4c 4e 95 a6 1c f2 32 9b 5c a6
   [769] d2 9d 8c 4b 24 79 e5 05 f1 96 b4 b5 3e 26 74 21 38 9b ff a5 46 2c 2a 9d
   [793] 45 5a 32 2d 3f 02 81 81 00 8b d6 06 44 73 c1 95 50 34 3a be 72 d4 78 29
   [817] a3 5b 3e 9f c8 84 72 38 db 13 d8 5d 68 e0 fe ea f5 25 f5 fc e0 17 ef 36
   [841] 2d b4 14 d3 22 48 6a 7c cc dd f5 08 e8 b6 25 0d f7 b6 41 45 6e a1 e2 e8
   [865] 10 a3 05 d3 36 05 99 0b a6 3a a9 59 bd 0d 6e 8f d8 95 ad ae 89 66 d1 ca
   [889] 47 47 15 15 32 33 31 2a fe 29 d7 ca d6 d6 35 19 11 8f 9e 4e e3 6e 74 9c
   [913] 9c cf d2 38 d1 8c 0a 5d 7d cc 15 21 58 66 da e0 e1 02 81 80 71 c9 03 8d
   [937] f6 4b 19 83 86 14 ce d1 70 d7 e7 32 76 a3 e2 af 33 e2 95 9e f1 dd 06 50
   [961] c5 53 bc c7 22 60 a1 39 9e 4a 83 45 c6 a4 f5 3b 67 83 20 dc 90 b5 b5 d5
   [985] d8 20 ba 59 ba 25 7c e7 54 a6 fe f2 cd a8 78 0b 13 8e a2 f4 0d 17 ab b7
  [1009] 3a 85 65 7e b9 12 a3 46 dc 62 15 8c bc a9 66 21 24 52 f0 eb 33 a3 9a 1d
  [1033] 53 06 f0 29 f7 3d 67 1c f9 e8 93 d4 b1 bd 95 2f 66 ee d9 b6 30 e8 67 40
  [1057] 93 41 9e 1d 02 81 80 26 79 95 eb 4b 1c 61 7a ad ec 7c e3 8f b1 7b 8e c7
  [1081] a3 18 ee d9 1e d6 ee e3 96 1f 28 bd d2 e2 03 19 d7 bf 3e eb 99 84 cf 07
  [1105] 1a 74 91 46 8f 52 f0 a9 d7 60 9a e2 b5 23 64 4f e1 7c f7 9a 32 1f b0 07
  [1129] 6e 72 81 72 9f 10 02 b6 ce 05 13 0f 03 b3 9f eb 52 23 cc be e9 41 c2 d2
  [1153] 0f 98 73 9f 01 20 c1 4f 1d 15 2f 4e e0 74 4a ab 8f fe 00 41 b4 a1 b0 65
  [1177] 59 d8 5e ab a3 ad 98 98 ab dd 10 bb 1f 2c 6c
  attr(,"class")
  [1] "private.key.DER"
  > PKI.load.key(file=fn.priv.pem)
  <pointer: 0x00000178fabf7300>
  attr(,"class")
  [1] "private.key"
  > PKI.load.key(file=fn.priv.der, format="DER", private=TRUE)
  <pointer: 0x00000178fabf6c20>
  attr(,"class")
  [1] "private.key"
  > fn.pub.pem <- tempfile()
  > PKI.save.key(key, target=fn.pub.pem, private=FALSE)
  [1] "-----BEGIN PUBLIC KEY-----"                                      
  [2] "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkGbcC4F0Bp0aGV9EC23"
  [3] "x2FdWUIKmUl0/bYjrlFjY3K83aEx/37YwQbVkqvoTKRWWWawbeSp28pVTWSgXOpG"
  [4] "p6XbSixm2dv7NPdte22YmuKAUMftf4IyENknEYzP68E2xhelOHoh5pAvO+UgXS+E"
  [5] "UKWDGLcNAbSSrLH6xpJvH2dBKW+2I3ZGntP9zB+4fiXmppgEonHD6am5freGvjLw"
  [6] "z9A7meKpAYKFSWnp5iusIg8Ygys3+mjhiLkaUPu1zwl73nF9QKwI45tBsAgj7VVN"
  [7] "iQlglQvYC+uwYNQ7EFcng89lZ3dkptZtU6IHzuD6uhg+0ZapKpgQbv4XSEG+/Wv2"
  [8] "kQIDAQAB"                                                        
  [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 9a 41 9b 70 2e 05 d0 1a 74 68 65 7d 10 2d b7 c7 61
   [51] 5d 59 42 0a 99 49 74 fd b6 23 ae 51 63 63 72 bc dd a1 31 ff 7e d8 c1 06 d5
   [76] 92 ab e8 4c a4 56 59 66 b0 6d e4 a9 db ca 55 4d 64 a0 5c ea 46 a7 a5 db 4a
  [101] 2c 66 d9 db fb 34 f7 6d 7b 6d 98 9a e2 80 50 c7 ed 7f 82 32 10 d9 27 11 8c
  [126] cf eb c1 36 c6 17 a5 38 7a 21 e6 90 2f 3b e5 20 5d 2f 84 50 a5 83 18 b7 0d
  [151] 01 b4 92 ac b1 fa c6 92 6f 1f 67 41 29 6f b6 23 76 46 9e d3 fd cc 1f b8 7e
  [176] 25 e6 a6 98 04 a2 71 c3 e9 a9 b9 7e b7 86 be 32 f0 cf d0 3b 99 e2 a9 01 82
  [201] 85 49 69 e9 e6 2b ac 22 0f 18 83 2b 37 fa 68 e1 88 b9 1a 50 fb b5 cf 09 7b
  [226] de 71 7d 40 ac 08 e3 9b 41 b0 08 23 ed 55 4d 89 09 60 95 0b d8 0b eb b0 60
  [251] d4 3b 10 57 27 83 cf 65 67 77 64 a6 d6 6d 53 a2 07 ce e0 fa ba 18 3e d1 96
  [276] a9 2a 98 10 6e fe 17 48 41 be fd 6b f6 91 02 03 01 00 01
  attr(,"class")
  [1] "public.key.DER"
  > PKI.load.key(file=fn.pub.pem)
  <pointer: 0x00000178fabf6cc0>
  attr(,"class")
  [1] "public.key"
  > PKI.load.key(file=fn.pub.der, format="DER", private=FALSE)
  <pointer: 0x00000178fabf6ae0>
  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