Botan  1.11.15
Public Types | Public Member Functions
Botan::TLS::Alert Class Reference

#include <tls_alert.h>

List of all members.

Public Types

enum  Type {
  CLOSE_NOTIFY = 0, UNEXPECTED_MESSAGE = 10, BAD_RECORD_MAC = 20, DECRYPTION_FAILED = 21,
  RECORD_OVERFLOW = 22, DECOMPRESSION_FAILURE = 30, HANDSHAKE_FAILURE = 40, NO_CERTIFICATE = 41,
  BAD_CERTIFICATE = 42, UNSUPPORTED_CERTIFICATE = 43, CERTIFICATE_REVOKED = 44, CERTIFICATE_EXPIRED = 45,
  CERTIFICATE_UNKNOWN = 46, ILLEGAL_PARAMETER = 47, UNKNOWN_CA = 48, ACCESS_DENIED = 49,
  DECODE_ERROR = 50, DECRYPT_ERROR = 51, EXPORT_RESTRICTION = 60, PROTOCOL_VERSION = 70,
  INSUFFICIENT_SECURITY = 71, INTERNAL_ERROR = 80, INAPPROPRIATE_FALLBACK = 86, USER_CANCELED = 90,
  NO_RENEGOTIATION = 100, UNSUPPORTED_EXTENSION = 110, CERTIFICATE_UNOBTAINABLE = 111, UNRECOGNIZED_NAME = 112,
  BAD_CERTIFICATE_STATUS_RESPONSE = 113, BAD_CERTIFICATE_HASH_VALUE = 114, UNKNOWN_PSK_IDENTITY = 115, NULL_ALERT = 256,
  HEARTBEAT_PAYLOAD = 257
}

Public Member Functions

 Alert (const secure_vector< byte > &buf)
 Alert (Type type_code, bool fatal=false)
 Alert ()
bool is_fatal () const
bool is_valid () const
std::vector< byteserialize () const
Type type () const
std::string type_string () const

Detailed Description

SSL/TLS Alert Message

Definition at line 21 of file tls_alert.h.


Member Enumeration Documentation

Type codes for TLS alerts

Enumerator:
CLOSE_NOTIFY 
UNEXPECTED_MESSAGE 
BAD_RECORD_MAC 
DECRYPTION_FAILED 
RECORD_OVERFLOW 
DECOMPRESSION_FAILURE 
HANDSHAKE_FAILURE 
NO_CERTIFICATE 
BAD_CERTIFICATE 
UNSUPPORTED_CERTIFICATE 
CERTIFICATE_REVOKED 
CERTIFICATE_EXPIRED 
CERTIFICATE_UNKNOWN 
ILLEGAL_PARAMETER 
UNKNOWN_CA 
ACCESS_DENIED 
DECODE_ERROR 
DECRYPT_ERROR 
EXPORT_RESTRICTION 
PROTOCOL_VERSION 
INSUFFICIENT_SECURITY 
INTERNAL_ERROR 
INAPPROPRIATE_FALLBACK 
USER_CANCELED 
NO_RENEGOTIATION 
UNSUPPORTED_EXTENSION 
CERTIFICATE_UNOBTAINABLE 
UNRECOGNIZED_NAME 
BAD_CERTIFICATE_STATUS_RESPONSE 
BAD_CERTIFICATE_HASH_VALUE 
UNKNOWN_PSK_IDENTITY 
NULL_ALERT 
HEARTBEAT_PAYLOAD 

Definition at line 27 of file tls_alert.h.


Constructor & Destructor Documentation

Botan::TLS::Alert::Alert ( const secure_vector< byte > &  buf)

Deserialize an Alert message

Parameters:
bufthe serialized alert

Definition at line 15 of file tls_alert.cpp.

References Botan::ASN1::to_string().

   {
   if(buf.size() != 2)
      throw Decoding_Error("Alert: Bad size " + std::to_string(buf.size()) +
                           " for alert message");

   if(buf[0] == 1)      m_fatal = false;
   else if(buf[0] == 2) m_fatal = true;
   else
      throw Decoding_Error("Alert: Bad code for alert level");

   const byte dc = buf[1];

   m_type_code = static_cast<Type>(dc);
   }
Botan::TLS::Alert::Alert ( Type  type_code,
bool  fatal = false 
) [inline]

Create a new Alert

Parameters:
type_codethe type of alert
fatalspecifies if this is a fatal alert

Definition at line 101 of file tls_alert.h.

                                                :
         m_fatal(fatal), m_type_code(type_code) {}

Definition at line 104 of file tls_alert.h.

: m_fatal(false), m_type_code(NULL_ALERT) {}

Member Function Documentation

bool Botan::TLS::Alert::is_fatal ( ) const [inline]
Returns:
if this alert is a fatal one or not

Definition at line 73 of file tls_alert.h.

Referenced by Botan::TLS::Channel::received_data(), Botan::TLS::Channel::send_alert(), and serialize().

{ return m_fatal; }
bool Botan::TLS::Alert::is_valid ( ) const [inline]
Returns:
true iff this alert is non-empty

Definition at line 68 of file tls_alert.h.

Referenced by Botan::TLS::Channel::send_alert().

{ return (m_type_code != NULL_ALERT); }
std::vector< byte > Botan::TLS::Alert::serialize ( ) const

Serialize an alert

Definition at line 31 of file tls_alert.cpp.

References is_fatal(), and type().

Referenced by Botan::TLS::Channel::send_alert().

   {
   return std::vector<byte>({
      static_cast<byte>(is_fatal() ? 2 : 1),
      static_cast<byte>(type())
      });
   }
Type Botan::TLS::Alert::type ( ) const [inline]
Returns:
type of alert

Definition at line 78 of file tls_alert.h.

Referenced by Botan::TLS::Channel::received_data(), Botan::TLS::Channel::send_alert(), serialize(), and type_string().

{ return m_type_code; }
std::string Botan::TLS::Alert::type_string ( ) const
Returns:
type of alert

Definition at line 39 of file tls_alert.cpp.

References ACCESS_DENIED, BAD_CERTIFICATE, BAD_CERTIFICATE_HASH_VALUE, BAD_CERTIFICATE_STATUS_RESPONSE, BAD_RECORD_MAC, CERTIFICATE_EXPIRED, CERTIFICATE_REVOKED, CERTIFICATE_UNKNOWN, CERTIFICATE_UNOBTAINABLE, CLOSE_NOTIFY, DECODE_ERROR, DECOMPRESSION_FAILURE, DECRYPT_ERROR, DECRYPTION_FAILED, EXPORT_RESTRICTION, HANDSHAKE_FAILURE, HEARTBEAT_PAYLOAD, ILLEGAL_PARAMETER, INAPPROPRIATE_FALLBACK, INSUFFICIENT_SECURITY, INTERNAL_ERROR, NO_CERTIFICATE, NO_RENEGOTIATION, NULL_ALERT, PROTOCOL_VERSION, RECORD_OVERFLOW, Botan::ASN1::to_string(), type(), UNEXPECTED_MESSAGE, UNKNOWN_CA, UNKNOWN_PSK_IDENTITY, UNRECOGNIZED_NAME, UNSUPPORTED_CERTIFICATE, UNSUPPORTED_EXTENSION, and USER_CANCELED.

   {
   switch(type())
      {
      case CLOSE_NOTIFY:
         return "close_notify";
      case UNEXPECTED_MESSAGE:
         return "unexpected_message";
      case BAD_RECORD_MAC:
         return "bad_record_mac";
      case DECRYPTION_FAILED:
         return "decryption_failed";
      case RECORD_OVERFLOW:
         return "record_overflow";
      case DECOMPRESSION_FAILURE:
         return "decompression_failure";
      case HANDSHAKE_FAILURE:
         return "handshake_failure";
      case NO_CERTIFICATE:
         return "no_certificate";
      case BAD_CERTIFICATE:
         return "bad_certificate";
      case UNSUPPORTED_CERTIFICATE:
         return "unsupported_certificate";
      case CERTIFICATE_REVOKED:
         return "certificate_revoked";
      case CERTIFICATE_EXPIRED:
         return "certificate_expired";
      case CERTIFICATE_UNKNOWN:
         return "certificate_unknown";
      case ILLEGAL_PARAMETER:
         return "illegal_parameter";
      case UNKNOWN_CA:
         return "unknown_ca";
      case ACCESS_DENIED:
         return "access_denied";
      case DECODE_ERROR:
         return "decode_error";
      case DECRYPT_ERROR:
         return "decrypt_error";
      case EXPORT_RESTRICTION:
         return "export_restriction";
      case PROTOCOL_VERSION:
         return "protocol_version";
      case INSUFFICIENT_SECURITY:
         return "insufficient_security";
      case INTERNAL_ERROR:
         return "internal_error";
      case INAPPROPRIATE_FALLBACK:
         return "inappropriate_fallback";
      case USER_CANCELED:
         return "user_canceled";
      case NO_RENEGOTIATION:
         return "no_renegotiation";

      case UNSUPPORTED_EXTENSION:
         return "unsupported_extension";
      case CERTIFICATE_UNOBTAINABLE:
         return "certificate_unobtainable";
      case UNRECOGNIZED_NAME:
         return "unrecognized_name";
      case BAD_CERTIFICATE_STATUS_RESPONSE:
         return "bad_certificate_status_response";
      case BAD_CERTIFICATE_HASH_VALUE:
         return "bad_certificate_hash_value";
      case UNKNOWN_PSK_IDENTITY:
         return "unknown_psk_identity";

      case NULL_ALERT:
         return "none";

      case HEARTBEAT_PAYLOAD:
         return "heartbeat_payload";
      }

   /*
   * This is effectively the default case for the switch above, but we
   * leave it out so that when an alert type is added to the enum the
   * compiler can warn us that it is not included in the switch
   * statement.
   */
   return "unrecognized_alert_" + std::to_string(type());
   }

The documentation for this class was generated from the following files: