// ---------------------------------------------------------------------------
// - TlsProto12.hpp                                                          -
// - afnix:tls service - tls protocol 1.2 class definition                   -
// ---------------------------------------------------------------------------
// - This program is free software;  you can redistribute it  and/or  modify -
// - it provided that this copyright notice is kept intact.                  -
// -                                                                         -
// - 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.  In no event shall -
// - the copyright holder be liable for any  direct, indirect, incidental or -
// - special damages arising in any way out of the use of this software.     -
// ---------------------------------------------------------------------------
// - copyright (c) 1999-2019 amaury darsch                                   -
// ---------------------------------------------------------------------------

#ifndef  AFNIX_TLSPROTO12_HPP
#define  AFNIX_TLSPROTO12_HPP

#ifndef  AFNIX_TLSPROTO_HPP
#include "TlsProto.hpp"
#endif

namespace afnix {

  /// The TlsProto12 class is the tls protocol extension starting at version
  /// 1.2. The protocol is merely the same, except the prf function which is
  /// based here on sha256.
  /// @author amaury darsch

  class TlsProto12 : public TlsProto {
  public:
    /// create a default protocol
    TlsProto12 (void);

    /// @return the class name
    String repr (void) const;

    /// compute a hash buffer by prf
    /// @param sbuf the secret buffer
    /// @param labl the prf label
    /// @param seed the prf seed
    /// @param rlen the prf result size
    Buffer xprf (const Buffer& sbuf, const String& labl, const Buffer& seed,
		 const long    rlen) const;

    /// compute the server verify buffer
    /// @param mbuf the master secret
    /// @param vbuf the verify buffer 
    Buffer sfin (const Buffer& mbuf, const Buffer& vbuf) const;
    
    /// compute the client verify buffer
    /// @param mbuf the master secret
    /// @param vbuf the verify buffer 
    Buffer cfin (const Buffer& mbuf, const Buffer& vbuf) const;
    
  public:
    /// create a new object in a generic way
    /// @param argv the argument vector
    static Object* mknew (Vector* argv);
  };
}

#endif
