(**************************************************************************)
(*                                                                        *)
(*  Encryption library                                                    *)
(*  Copyright (C) 2017   Peter Moylan                                     *)
(*                                                                        *)
(*  This program is free software: you can redistribute it and/or modify  *)
(*  it under the terms of the GNU General Public License as published by  *)
(*  the Free Software Foundation, either version 3 of the License, or     *)
(*  (at your option) any later version.                                   *)
(*                                                                        *)
(*  This program is distributed in the hope that it will be useful,       *)
(*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *)
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *)
(*  GNU General Public License for more details.                          *)
(*                                                                        *)
(*  You should have received a copy of the GNU General Public License     *)
(*  along with this program.  If not, see <http://www.gnu.org/licenses/>. *)
(*                                                                        *)
(*  To contact author:   http://www.pmoylan.org   peter@pmoylan.org       *)
(*                                                                        *)
(**************************************************************************)


DEFINITION MODULE TLSPRF;

        (********************************************************)
        (*                                                      *)
        (*      Pseudo-random function for key generation       *)
        (*         as specified in RFC 5246, section 5.         *)
        (*                                                      *)
        (*  Programmer:         P. Moylan                       *)
        (*  Started:            6 October 2017                  *)
        (*  Last edited:        4 November 2022                 *)
        (*  Status:             Complete but untested           *)
        (*                                                      *)
        (********************************************************)


FROM SYSTEM IMPORT CARD8;


TYPE PRFAlgorithm = (tls_prf_sha256);


PROCEDURE PRF (prf_alg: PRFAlgorithm;  secretlength: CARDINAL;  secret: ARRAY OF CARD8;
                label: ARRAY OF CHAR;
                seedlength: CARDINAL;  seed: ARRAY OF CARD8;
                needed: CARDINAL;  VAR (*OUT*) result: ARRAY OF CARD8);

    (* The pseudo-random function of RFC 5246, section 5.  The 'needed' *)
    (* parameter says how long result must be.                          *)

END TLSPRF.

