Skip to content

Commit

Permalink
Remove old code, related to key generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Oct 21, 2024
1 parent 22d9485 commit 01c860e
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 904 deletions.
66 changes: 0 additions & 66 deletions src/lib/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,69 +48,3 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "config.h"

#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif

#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
__RCSID("$NetBSD: crypto.c,v 1.36 2014/02/17 07:39:19 agc Exp $");
#endif

#include <sys/types.h>
#include <sys/stat.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#include <string.h>
#include <time.h>
#include <rnp/rnp_def.h>

#include <librepgp/stream-packet.h>
#include <librepgp/stream-key.h>

#include "types.h"
#include "crypto/common.h"
#include "crypto.h"
#include "fingerprint.h"
#include "pgp-key.h"
#include "utils.h"

bool
pgp_generate_seckey(const rnp_keygen_crypto_params_t &crypto,
pgp_key_pkt_t & seckey,
bool primary,
pgp_version_t pgp_version)
{
/* populate pgp key structure */
seckey = {};
#if defined(ENABLE_CRYPTO_REFRESH)
seckey.version = pgp_version;
#else
seckey.version = PGP_V4;
#endif
seckey.creation_time = crypto.ctx->time();
seckey.alg = crypto.key_alg;
seckey.material = pgp::KeyMaterial::create(crypto.key_alg);
if (!seckey.material) {
RNP_LOG("Unsupported key algorithm: %d", crypto.key_alg);
return false;
}
seckey.tag = primary ? PGP_PKT_SECRET_KEY : PGP_PKT_SECRET_SUBKEY;

if (!seckey.material->generate(crypto)) {
return false;
}

seckey.sec_protection.s2k.usage = PGP_S2KU_NONE;
/* fill the sec_data/sec_len */
if (encrypt_secret_key(&seckey, NULL, crypto.ctx->rng)) {
RNP_LOG("failed to fill sec_data");
return false;
}
return true;
}
45 changes: 0 additions & 45 deletions src/lib/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,49 +59,4 @@
#include "crypto/common.h"
#include <rekey/rnp_key_store.h>

/* raw key generation */
bool pgp_generate_seckey(const rnp_keygen_crypto_params_t &params,
pgp_key_pkt_t & seckey,
bool primary,
pgp_version_t pgp_version = PGP_V4);

/** generate a new primary key
*
* @param desc keygen description
* @param merge_defaults true if you want defaults to be set for unset
* keygen description parameters.
* @param primary_sec pointer to store the generated secret key, must not be NULL
* @param primary_pub pointer to store the generated public key, must not be NULL
* @return true if successful, false otherwise.
**/
bool pgp_generate_primary_key(rnp_keygen_primary_desc_t &desc,
bool merge_defaults,
pgp_key_t & primary_sec,
pgp_key_t & primary_pub,
pgp_key_store_format_t secformat);

/** generate a new subkey
*
* @param desc keygen description
* @param merge_defaults true if you want defaults to be set for unset
* keygen description parameters.
* @param primary_sec pointer to the primary secret key that will own this
* subkey, must not be NULL
* @param primary_pub pointer to the primary public key that will own this
* subkey, must not be NULL
* @param subkey_sec pointer to store the generated secret key, must not be NULL
* @param subkey_pub pointer to store the generated public key, must not be NULL
* @param password_provider the password provider that will be used to
* decrypt the primary key, may be NULL if primary key is unlocked
* @return true if successful, false otherwise.
**/
bool pgp_generate_subkey(rnp_keygen_subkey_desc_t & desc,
bool merge_defaults,
pgp_key_t & primary_sec,
pgp_key_t & primary_pub,
pgp_key_t & subkey_sec,
pgp_key_t & subkey_pub,
const pgp_password_provider_t &password_provider,
pgp_key_store_format_t secformat);

#endif /* CRYPTO_H_ */
Loading

0 comments on commit 01c860e

Please sign in to comment.