aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/if_algo/if_algo.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey/if_algo/if_algo.h')
-rw-r--r--src/lib/pubkey/if_algo/if_algo.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/lib/pubkey/if_algo/if_algo.h b/src/lib/pubkey/if_algo/if_algo.h
new file mode 100644
index 000000000..7dd6d19f0
--- /dev/null
+++ b/src/lib/pubkey/if_algo/if_algo.h
@@ -0,0 +1,108 @@
+/*
+* IF Scheme
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_IF_ALGO_H__
+#define BOTAN_IF_ALGO_H__
+
+#include <botan/bigint.h>
+#include <botan/x509_key.h>
+#include <botan/pkcs8.h>
+
+namespace Botan {
+
+/**
+* This class represents public keys
+* of integer factorization based (IF) public key schemes.
+*/
+class BOTAN_DLL IF_Scheme_PublicKey : public virtual Public_Key
+ {
+ public:
+ IF_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
+ const secure_vector<byte>& key_bits);
+
+ IF_Scheme_PublicKey(const BigInt& n, const BigInt& e) :
+ n(n), e(e) {}
+
+ bool check_key(RandomNumberGenerator& rng, bool) const;
+
+ AlgorithmIdentifier algorithm_identifier() const;
+
+ std::vector<byte> x509_subject_public_key() const;
+
+ /**
+ * @return public modulus
+ */
+ const BigInt& get_n() const { return n; }
+
+ /**
+ * @return public exponent
+ */
+ const BigInt& get_e() const { return e; }
+
+ size_t max_input_bits() const { return (n.bits() - 1); }
+
+ size_t estimated_strength() const override;
+
+ protected:
+ IF_Scheme_PublicKey() {}
+
+ BigInt n, e;
+ };
+
+/**
+* This class represents public keys
+* of integer factorization based (IF) public key schemes.
+*/
+class BOTAN_DLL IF_Scheme_PrivateKey : public virtual IF_Scheme_PublicKey,
+ public virtual Private_Key
+ {
+ public:
+
+ IF_Scheme_PrivateKey(RandomNumberGenerator& rng,
+ const BigInt& prime1, const BigInt& prime2,
+ const BigInt& exp, const BigInt& d_exp,
+ const BigInt& mod);
+
+ IF_Scheme_PrivateKey(RandomNumberGenerator& rng,
+ const AlgorithmIdentifier& alg_id,
+ const secure_vector<byte>& key_bits);
+
+ bool check_key(RandomNumberGenerator& rng, bool) const;
+
+ /**
+ * Get the first prime p.
+ * @return prime p
+ */
+ const BigInt& get_p() const { return p; }
+
+ /**
+ * Get the second prime q.
+ * @return prime q
+ */
+ const BigInt& get_q() const { return q; }
+
+ /**
+ * Get d with exp * d = 1 mod (p - 1, q - 1).
+ * @return d
+ */
+ const BigInt& get_d() const { return d; }
+
+ const BigInt& get_c() const { return c; }
+ const BigInt& get_d1() const { return d1; }
+ const BigInt& get_d2() const { return d2; }
+
+ secure_vector<byte> pkcs8_private_key() const;
+
+ protected:
+ IF_Scheme_PrivateKey() {}
+
+ BigInt d, p, q, d1, d2, c;
+ };
+
+}
+
+#endif