]> git.ipfire.org Git - thirdparty/openssl.git/blame - util/perl/TLSProxy/HelloVerifyRequest.pm
Copyright year updates
[thirdparty/openssl.git] / util / perl / TLSProxy / HelloVerifyRequest.pm
CommitLineData
0ce7d1f3 1# Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
a1c72cc2
FWH
2#
3# Licensed under the Apache License 2.0 (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
8use strict;
9
10package TLSProxy::HelloVerifyRequest;
11
12use TLSProxy::Record;
13
14use vars '@ISA';
15push @ISA, 'TLSProxy::Message';
16
17
18sub new
19{
20 my $class = shift;
21 my ($isdtls,
22 $server,
23 $msgseq,
24 $msgfrag,
25 $msgfragoffs,
26 $data,
27 $records,
28 $startoffset,
29 $message_frag_lens) = @_;
30
31 my $self = $class->SUPER::new(
32 $isdtls,
33 $server,
34 TLSProxy::Message::MT_HELLO_VERIFY_REQUEST,
35 $msgseq,
36 $msgfrag,
37 $msgfragoffs,
38 $data,
39 $records,
40 $startoffset,
41 $message_frag_lens);
42
43 $self->{server_version} = 0;
44 $self->{cookie_len} = 0;
45 $self->{cookie} = "";
46
47 return $self;
48}
49
50sub parse
51{
52 my $self = shift;
53
54 my ($server_version) = unpack('n', $self->data);
55 my $ptr = 2;
56 my $cookie_len = unpack('C', substr($self->data, $ptr));
57 $ptr++;
58 my $cookie = substr($self->data, $ptr, $cookie_len);
59
60 $self->server_version($server_version);
61 $self->cookie_len($cookie_len);
62 $self->cookie($cookie);
63
64 $self->process_data();
65
66 print " Server Version:".$TLSProxy::Record::tls_version{$server_version}."\n";
67 print " Cookie Len:".$cookie_len."\n";
68}
69
70#Perform any actions necessary based on the data we've seen
71sub process_data
72{
73 my $self = shift;
74 #Intentional no-op
75}
76
77#Reconstruct the on-the-wire message data following changes
78sub set_message_contents
79{
80 my $self = shift;
81 my $data;
82
83 $data = pack('n', $self->server_version);
84 $data .= pack('C', $self->cookie_len);
85 $data .= $self->cookie;
86
87 $self->data($data);
88}
89
90#Read/write accessors
91sub server_version
92{
93 my $self = shift;
94 if (@_) {
95 $self->{server_version} = shift;
96 }
97 return $self->{server_version};
98}
99sub cookie_len
100{
101 my $self = shift;
102 if (@_) {
103 $self->{cookie_len} = shift;
104 }
105 return $self->{cookie_len};
106}
107sub cookie
108{
109 my $self = shift;
110 if (@_) {
111 $self->{cookie} = shift;
112 }
113 return $self->{cookie};
114}
1151;