]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[sedhcpv6] moved from_bind9 to private key
authorFrancis Dupont <fdupont@isc.org>
Fri, 5 Jun 2015 16:26:57 +0000 (18:26 +0200)
committerFrancis Dupont <fdupont@isc.org>
Fri, 5 Jun 2015 16:26:57 +0000 (18:26 +0200)
src/lib/cryptolink/tests/from_bind9.cc

index 99a320ba63f5a10836db72f18f79d14966d39fd3..0ab4725511c6e1d1554bb36034d75754ec19d032 100644 (file)
@@ -35,26 +35,21 @@ int main(int argc, char* argv[]) {
     // Get the public key from DNS
     CryptoLink& crypto = CryptoLink::getCryptoLink();
     string keyfile = argv[1];
-    keyfile += ".key";
+    keyfile += ".private";
     boost::shared_ptr<Asym> key(crypto.createAsym(keyfile, "",
                                                   RSA_, SHA256,
-                                                  PUBLIC, DNS),
+                                                  PRIVATE, DNS),
                                 deleteAsym);
     if (!key) {
         cerr << "createAsym failed" << endl;
         return (-1);
     }
 
-    // Export the public key in SubjectPublicKeyInfo der on stdout
-    const std::vector<uint8_t> keybin = key->exportkey(PUBLIC, ASN1);
-    const ssize_t cc = write(1, &keybin[0], keybin.size());
-    if (cc < 0) {
-        cerr << "write failed" << endl;
-        return (-1);
-    }
-    if (static_cast<size_t>(cc) != keybin.size()) {
-        cerr << "truncated write" << endl;
-        return (-1);
-    }
+    // Export the private key in PKCS#8 format
+
+    keyfile = argv[1];
+    keyfile += ".pkcs8";
+    key->exportkey(keyfile, "", PRIVATE, ASN1);
+
     return (0);
 }