123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559 |
- /* $OpenBSD: test_file.c,v 1.9 2020/06/19 03:48:49 djm Exp $ */
- /*
- * Regress test for sshkey.h key management API
- *
- * Placed in the public domain
- */
- #include "includes.h"
- #include <sys/types.h>
- #include <sys/param.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <stdio.h>
- #ifdef HAVE_STDINT_H
- #include <stdint.h>
- #endif
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #ifdef WITH_OPENSSL
- #include <openssl/bn.h>
- #include <openssl/rsa.h>
- #include <openssl/dsa.h>
- #include <openssl/objects.h>
- #ifdef OPENSSL_HAS_NISTP256
- # include <openssl/ec.h>
- #endif /* OPENSSL_HAS_NISTP256 */
- #endif /* WITH_OPENSSL */
- #include "../test_helper/test_helper.h"
- #include "ssherr.h"
- #include "authfile.h"
- #include "sshkey.h"
- #include "sshbuf.h"
- #include "digest.h"
- #include "common.h"
- void sshkey_file_tests(void);
- void
- sshkey_file_tests(void)
- {
- struct sshkey *k1, *k2;
- struct sshbuf *buf, *pw;
- #ifdef WITH_OPENSSL
- BIGNUM *a, *b, *c;
- #endif
- char *cp;
- TEST_START("load passphrase");
- pw = load_text_file("pw");
- TEST_DONE();
- #ifdef WITH_OPENSSL
- TEST_START("parse RSA from private");
- buf = load_file("rsa_1");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k1, NULL);
- a = load_bignum("rsa_1.param.n");
- b = load_bignum("rsa_1.param.p");
- c = load_bignum("rsa_1.param.q");
- ASSERT_BIGNUM_EQ(rsa_n(k1), a);
- ASSERT_BIGNUM_EQ(rsa_p(k1), b);
- ASSERT_BIGNUM_EQ(rsa_q(k1), c);
- BN_free(a);
- BN_free(b);
- BN_free(c);
- TEST_DONE();
- TEST_START("parse RSA from private w/ passphrase");
- buf = load_file("rsa_1_pw");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
- (const char *)sshbuf_ptr(pw), &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("parse RSA from new-format");
- buf = load_file("rsa_n");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("parse RSA from new-format w/ passphrase");
- buf = load_file("rsa_n_pw");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
- (const char *)sshbuf_ptr(pw), &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load RSA from public");
- ASSERT_INT_EQ(sshkey_load_public(test_data_file("rsa_1.pub"), &k2,
- NULL), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load RSA cert with SHA1 signature");
- ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1_sha1"), &k2), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(k2->type, KEY_RSA_CERT);
- ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1);
- ASSERT_STRING_EQ(k2->cert->signature_type, "ssh-rsa");
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load RSA cert with SHA512 signature");
- ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1_sha512"), &k2), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(k2->type, KEY_RSA_CERT);
- ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1);
- ASSERT_STRING_EQ(k2->cert->signature_type, "rsa-sha2-512");
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load RSA cert");
- ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1"), &k2), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(k2->type, KEY_RSA_CERT);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 0);
- ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1);
- TEST_DONE();
- TEST_START("RSA key hex fingerprint");
- buf = load_text_file("rsa_1.fp");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- TEST_START("RSA cert hex fingerprint");
- buf = load_text_file("rsa_1-cert.fp");
- cp = sshkey_fingerprint(k2, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("RSA key bubblebabble fingerprint");
- buf = load_text_file("rsa_1.fp.bb");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA1, SSH_FP_BUBBLEBABBLE);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- sshkey_free(k1);
- TEST_START("parse DSA from private");
- buf = load_file("dsa_1");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k1, NULL);
- a = load_bignum("dsa_1.param.g");
- b = load_bignum("dsa_1.param.priv");
- c = load_bignum("dsa_1.param.pub");
- ASSERT_BIGNUM_EQ(dsa_g(k1), a);
- ASSERT_BIGNUM_EQ(dsa_priv_key(k1), b);
- ASSERT_BIGNUM_EQ(dsa_pub_key(k1), c);
- BN_free(a);
- BN_free(b);
- BN_free(c);
- TEST_DONE();
- TEST_START("parse DSA from private w/ passphrase");
- buf = load_file("dsa_1_pw");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
- (const char *)sshbuf_ptr(pw), &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("parse DSA from new-format");
- buf = load_file("dsa_n");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("parse DSA from new-format w/ passphrase");
- buf = load_file("dsa_n_pw");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
- (const char *)sshbuf_ptr(pw), &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load DSA from public");
- ASSERT_INT_EQ(sshkey_load_public(test_data_file("dsa_1.pub"), &k2,
- NULL), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load DSA cert");
- ASSERT_INT_EQ(sshkey_load_cert(test_data_file("dsa_1"), &k2), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(k2->type, KEY_DSA_CERT);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 0);
- ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1);
- TEST_DONE();
- TEST_START("DSA key hex fingerprint");
- buf = load_text_file("dsa_1.fp");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- TEST_START("DSA cert hex fingerprint");
- buf = load_text_file("dsa_1-cert.fp");
- cp = sshkey_fingerprint(k2, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("DSA key bubblebabble fingerprint");
- buf = load_text_file("dsa_1.fp.bb");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA1, SSH_FP_BUBBLEBABBLE);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- sshkey_free(k1);
- #ifdef OPENSSL_HAS_ECC
- TEST_START("parse ECDSA from private");
- buf = load_file("ecdsa_1");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k1, NULL);
- buf = load_text_file("ecdsa_1.param.curve");
- ASSERT_STRING_EQ((const char *)sshbuf_ptr(buf),
- OBJ_nid2sn(k1->ecdsa_nid));
- sshbuf_free(buf);
- a = load_bignum("ecdsa_1.param.priv");
- b = load_bignum("ecdsa_1.param.pub");
- c = EC_POINT_point2bn(EC_KEY_get0_group(k1->ecdsa),
- EC_KEY_get0_public_key(k1->ecdsa), POINT_CONVERSION_UNCOMPRESSED,
- NULL, NULL);
- ASSERT_PTR_NE(c, NULL);
- ASSERT_BIGNUM_EQ(EC_KEY_get0_private_key(k1->ecdsa), a);
- ASSERT_BIGNUM_EQ(b, c);
- BN_free(a);
- BN_free(b);
- BN_free(c);
- TEST_DONE();
- TEST_START("parse ECDSA from private w/ passphrase");
- buf = load_file("ecdsa_1_pw");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
- (const char *)sshbuf_ptr(pw), &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("parse ECDSA from new-format");
- buf = load_file("ecdsa_n");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("parse ECDSA from new-format w/ passphrase");
- buf = load_file("ecdsa_n_pw");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
- (const char *)sshbuf_ptr(pw), &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load ECDSA from public");
- ASSERT_INT_EQ(sshkey_load_public(test_data_file("ecdsa_1.pub"), &k2,
- NULL), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load ECDSA cert");
- ASSERT_INT_EQ(sshkey_load_cert(test_data_file("ecdsa_1"), &k2), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(k2->type, KEY_ECDSA_CERT);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 0);
- ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1);
- TEST_DONE();
- TEST_START("ECDSA key hex fingerprint");
- buf = load_text_file("ecdsa_1.fp");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- TEST_START("ECDSA cert hex fingerprint");
- buf = load_text_file("ecdsa_1-cert.fp");
- cp = sshkey_fingerprint(k2, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("ECDSA key bubblebabble fingerprint");
- buf = load_text_file("ecdsa_1.fp.bb");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA1, SSH_FP_BUBBLEBABBLE);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- sshkey_free(k1);
- #endif /* OPENSSL_HAS_ECC */
- #endif /* WITH_OPENSSL */
- TEST_START("parse Ed25519 from private");
- buf = load_file("ed25519_1");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k1, NULL);
- ASSERT_INT_EQ(k1->type, KEY_ED25519);
- /* XXX check key contents */
- TEST_DONE();
- TEST_START("parse Ed25519 from private w/ passphrase");
- buf = load_file("ed25519_1_pw");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
- (const char *)sshbuf_ptr(pw), &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load Ed25519 from public");
- ASSERT_INT_EQ(sshkey_load_public(test_data_file("ed25519_1.pub"), &k2,
- NULL), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load Ed25519 cert");
- ASSERT_INT_EQ(sshkey_load_cert(test_data_file("ed25519_1"), &k2), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(k2->type, KEY_ED25519_CERT);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 0);
- ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1);
- TEST_DONE();
- TEST_START("Ed25519 key hex fingerprint");
- buf = load_text_file("ed25519_1.fp");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- TEST_START("Ed25519 cert hex fingerprint");
- buf = load_text_file("ed25519_1-cert.fp");
- cp = sshkey_fingerprint(k2, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("Ed25519 key bubblebabble fingerprint");
- buf = load_text_file("ed25519_1.fp.bb");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA1, SSH_FP_BUBBLEBABBLE);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- sshkey_free(k1);
- #if defined(WITH_OPENSSL) && defined(OPENSSL_HAS_ECC)
- TEST_START("parse ECDSA-SK from private");
- buf = load_file("ecdsa_sk1");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k1, NULL);
- ASSERT_INT_EQ(k1->type, KEY_ECDSA_SK);
- TEST_DONE();
- TEST_START("parse ECDSA-SK from private w/ passphrase");
- buf = load_file("ecdsa_sk1_pw");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
- (const char *)sshbuf_ptr(pw), &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load ECDSA-SK from public");
- ASSERT_INT_EQ(sshkey_load_public(test_data_file("ecdsa_sk1.pub"), &k2,
- NULL), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load ECDSA-SK cert");
- ASSERT_INT_EQ(sshkey_load_cert(test_data_file("ecdsa_sk1"), &k2), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(k2->type, KEY_ECDSA_SK_CERT);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 0);
- ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1);
- TEST_DONE();
- TEST_START("ECDSA-SK key hex fingerprint");
- buf = load_text_file("ecdsa_sk1.fp");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- TEST_START("ECDSA-SK cert hex fingerprint");
- buf = load_text_file("ecdsa_sk1-cert.fp");
- cp = sshkey_fingerprint(k2, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("ECDSA-SK key bubblebabble fingerprint");
- buf = load_text_file("ecdsa_sk1.fp.bb");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA1, SSH_FP_BUBBLEBABBLE);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- sshkey_free(k1);
- #endif
- TEST_START("parse Ed25519-SK from private");
- buf = load_file("ed25519_sk1");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k1, NULL);
- ASSERT_INT_EQ(k1->type, KEY_ED25519_SK);
- /* XXX check key contents */
- TEST_DONE();
- TEST_START("parse Ed25519-SK from private w/ passphrase");
- buf = load_file("ed25519_sk1_pw");
- ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf,
- (const char *)sshbuf_ptr(pw), &k2, NULL), 0);
- sshbuf_free(buf);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load Ed25519-SK from public");
- ASSERT_INT_EQ(sshkey_load_public(test_data_file("ed25519_sk1.pub"),
- &k2, NULL), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 1);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("load Ed25519-SK cert");
- ASSERT_INT_EQ(sshkey_load_cert(test_data_file("ed25519_sk1"), &k2), 0);
- ASSERT_PTR_NE(k2, NULL);
- ASSERT_INT_EQ(k2->type, KEY_ED25519_SK_CERT);
- ASSERT_INT_EQ(sshkey_equal(k1, k2), 0);
- ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1);
- TEST_DONE();
- TEST_START("Ed25519-SK key hex fingerprint");
- buf = load_text_file("ed25519_sk1.fp");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- TEST_START("Ed25519-SK cert hex fingerprint");
- buf = load_text_file("ed25519_sk1-cert.fp");
- cp = sshkey_fingerprint(k2, SSH_DIGEST_SHA256, SSH_FP_BASE64);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- sshkey_free(k2);
- TEST_DONE();
- TEST_START("Ed25519-SK key bubblebabble fingerprint");
- buf = load_text_file("ed25519_sk1.fp.bb");
- cp = sshkey_fingerprint(k1, SSH_DIGEST_SHA1, SSH_FP_BUBBLEBABBLE);
- ASSERT_PTR_NE(cp, NULL);
- ASSERT_STRING_EQ(cp, (const char *)sshbuf_ptr(buf));
- sshbuf_free(buf);
- free(cp);
- TEST_DONE();
- sshkey_free(k1);
- sshbuf_free(pw);
- }
|