DEFINITION MODULE RSAKeys;

        (********************************************************)
        (*                                                      *)
        (*              Defining the RSA key type               *)
        (*                                                      *)
        (*  Programmer:         P. Moylan                       *)
        (*  Last edited:        15 September 2023               *)
        (*  Status:             OK                              *)
        (*                                                      *)
        (*      In case you're wondering what RSA stands for,   *)
        (*      it's Rivest-Shamir-Adleman, after the           *)
        (*      inventors of the algorithm.                     *)
        (*                                                      *)
        (********************************************************)


FROM BigNum IMPORT (*type*) BN;

TYPE
    (* This appears to reveal a great deal of private information, but  *)
    (* note that almost all of this information is available only at    *)
    (* the "private" end of the connection.  At the other end, only     *)
    (* the "n" and "public" values are known.                           *)

    RSAKeyType =
            RECORD
                n, public, private: BN;

                (* The following fields are not, strictly speaking, *)
                (* required, but they allow faster decryption.      *)

                p, q, dp, dq, qinv: BN;

            END (*RECORD*);


PROCEDURE InitKey(): RSAKeyType;

    (* Returns a dummy key with no content. *)

PROCEDURE IsNilKey (k: RSAKeyType): BOOLEAN;

    (* Returns TRUE iff k is a key with no contents.  *)

PROCEDURE DiscardKey (VAR (*INOUT*) k: RSAKeyType);

    (* Discards the key data.  *)

END RSAKeys.

