SignatureInfo.h 2.35 KB
Newer Older
1 2 3 4 5 6 7 8
//========================================================================
//
// SignatureInfo.h
//
// This file is licensed under the GPLv2 or later
//
// Copyright 2015 André Guerreiro <aguerreiro1985@gmail.com>
// Copyright 2015 André Esser <bepandre@hotmail.com>
9
// Copyright 2015, 2017, 2018 Albert Astals Cid <aacid@kde.org>
10
// Copyright 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.de>
11
// Copyright 2018 Chinmoy Ranjan Pradhan <chinmoyrp65@protonmail.com>
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
//
//========================================================================

#ifndef SIGNATUREINFO_H
#define SIGNATUREINFO_H

#include <time.h>

enum SignatureValidationStatus
{
  SIGNATURE_VALID,
  SIGNATURE_INVALID,
  SIGNATURE_DIGEST_MISMATCH,
  SIGNATURE_DECODING_ERROR,
  SIGNATURE_GENERIC_ERROR,
  SIGNATURE_NOT_FOUND,
  SIGNATURE_NOT_VERIFIED
};

enum CertificateValidationStatus
{
  CERTIFICATE_TRUSTED,
34 35
  CERTIFICATE_UNTRUSTED_ISSUER,
  CERTIFICATE_UNKNOWN_ISSUER,
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
  CERTIFICATE_REVOKED,
  CERTIFICATE_EXPIRED,
  CERTIFICATE_GENERIC_ERROR,
  CERTIFICATE_NOT_VERIFIED
};

class SignatureInfo {
public:
  SignatureInfo();
  SignatureInfo(SignatureValidationStatus, CertificateValidationStatus);
  ~SignatureInfo();

  /* GETTERS */
  SignatureValidationStatus getSignatureValStatus();
  CertificateValidationStatus getCertificateValStatus();
51 52
  const char *getSignerName();
  const char *getSubjectDN();
53 54
  const char *getLocation() const;
  const char *getReason() const;
55
  int getHashAlgorithm(); // Returns a NSS3 HASH_HashType or -1 if compiled without NSS3
56 57 58 59 60 61 62
  time_t getSigningTime();
  bool isSubfilterSupported() { return sig_subfilter_supported; }

  /* SETTERS */
  void setSignatureValStatus(enum SignatureValidationStatus );
  void setCertificateValStatus(enum CertificateValidationStatus );
  void setSignerName(char *);
63
  void setSubjectDN(const char *);
64 65
  void setLocation(const char *);
  void setReason(const char *);
66
  void setHashAlgorithm(int);
67 68 69 70
  void setSigningTime(time_t);
  void setSubFilterSupport(bool isSupported) { sig_subfilter_supported = isSupported; }

private:
71 72 73
  SignatureInfo(const SignatureInfo &);
  SignatureInfo& operator=(const SignatureInfo &);

74 75 76
  SignatureValidationStatus sig_status;
  CertificateValidationStatus cert_status;
  char *signer_name;
77
  char *subject_dn;
78 79
  char *location;
  char *reason;
80
  int hash_type;
81 82 83 84 85
  time_t signing_time;
  bool sig_subfilter_supported;
};

#endif