2
0

CertificateVerify.pm 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
  2. #
  3. # Licensed under the OpenSSL license (the "License"). You may not use
  4. # this file except in compliance with the License. You can obtain a copy
  5. # in the file LICENSE in the source distribution or at
  6. # https://www.openssl.org/source/license.html
  7. use strict;
  8. package TLSProxy::CertificateVerify;
  9. use vars '@ISA';
  10. push @ISA, 'TLSProxy::Message';
  11. sub new
  12. {
  13. my $class = shift;
  14. my ($server,
  15. $data,
  16. $records,
  17. $startoffset,
  18. $message_frag_lens) = @_;
  19. my $self = $class->SUPER::new(
  20. $server,
  21. TLSProxy::Message::MT_CERTIFICATE_VERIFY,
  22. $data,
  23. $records,
  24. $startoffset,
  25. $message_frag_lens);
  26. $self->{sigalg} = -1;
  27. $self->{signature} = "";
  28. return $self;
  29. }
  30. sub parse
  31. {
  32. my $self = shift;
  33. my $sigalg = -1;
  34. my $remdata = $self->data;
  35. my $record = ${$self->records}[0];
  36. if (TLSProxy::Proxy->is_tls13()
  37. || $record->version() == TLSProxy::Record::VERS_TLS_1_2) {
  38. $sigalg = unpack('n', $remdata);
  39. $remdata = substr($remdata, 2);
  40. }
  41. my $siglen = unpack('n', substr($remdata, 0, 2));
  42. my $sig = substr($remdata, 2);
  43. die "Invalid CertificateVerify signature length" if length($sig) != $siglen;
  44. print " SigAlg:".$sigalg."\n";
  45. print " Signature Len:".$siglen."\n";
  46. $self->sigalg($sigalg);
  47. $self->signature($sig);
  48. }
  49. #Reconstruct the on-the-wire message data following changes
  50. sub set_message_contents
  51. {
  52. my $self = shift;
  53. my $data = "";
  54. my $sig = $self->signature();
  55. my $olddata = $self->data();
  56. $data .= pack("n", $self->sigalg()) if ($self->sigalg() != -1);
  57. $data .= pack("n", length($sig));
  58. $data .= $sig;
  59. $self->data($data);
  60. }
  61. #Read/write accessors
  62. sub sigalg
  63. {
  64. my $self = shift;
  65. if (@_) {
  66. $self->{sigalg} = shift;
  67. }
  68. return $self->{sigalg};
  69. }
  70. sub signature
  71. {
  72. my $self = shift;
  73. if (@_) {
  74. $self->{signature} = shift;
  75. }
  76. return $self->{signature};
  77. }
  78. 1;