| 1 | // Copyright 2009 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package tlsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/ |
| 6 | |
| 7 | import ( |
| 8 | "bytesscip-go gomod github.com/golang/go/src go1.16 bytes/" |
| 9 | "reflectscip-go gomod github.com/golang/go/src go1.16 reflect/" |
| 10 | ) |
| 11 | |
| 12 | type clientHelloMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg# struct { |
| 13 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#raw. []byte |
| 14 | versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#vers. uint16 |
| 15 | randomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#random. []byte |
| 16 | sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionId. []byte |
| 17 | cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites. []uint16 |
| 18 | compressionMethodsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#compressionMethods. []uint8 |
| 19 | nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#nextProtoNeg. bool |
| 20 | serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName. string |
| 21 | ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ocspStapling. bool |
| 22 | sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#scts. bool |
| 23 | supportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedCurves. []CurveIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/CurveID# |
| 24 | supportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedPoints. []uint8 |
| 25 | ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ticketSupported. bool |
| 26 | sessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionTicket. []uint8 |
| 27 | signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes. []SigAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash# |
| 28 | secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#secureRenegotiation. bool |
| 29 | heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatEnabled. bool |
| 30 | heartbeatModescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatMode. uint8 |
| 31 | extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandomEnabled. bool |
| 32 | extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandom. []byte |
| 33 | extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedMasterSecret. bool |
| 34 | sctEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sctEnabled. bool |
| 35 | alpnProtocolsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#alpnProtocols. []string |
| 36 | unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions. [][]byte |
| 37 | } |
| 38 | |
| 39 | func (m *clientHelloMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#equal().(i interface{}) bool { |
| 40 | m1, ok := i.(*clientHelloMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#) |
| 41 | if !ok { |
| 42 | return false |
| 43 | } |
| 44 | |
| 45 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#raw.) && |
| 46 | m.versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#vers. == m1.versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#vers. && |
| 47 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.randomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#random., m1.randomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#random.) && |
| 48 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionId., m1.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionId.) && |
| 49 | eqUint16sscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqUint16s().(m.cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites., m1.cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites.) && |
| 50 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.compressionMethodsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#compressionMethods., m1.compressionMethodsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#compressionMethods.) && |
| 51 | m.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#nextProtoNeg. == m1.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#nextProtoNeg. && |
| 52 | m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName. == m1.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName. && |
| 53 | m.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ocspStapling. == m1.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ocspStapling. && |
| 54 | m.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#scts. == m1.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#scts. && |
| 55 | eqCurveIDsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqCurveIDs().(m.supportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedCurves., m1.supportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedCurves.) && |
| 56 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.supportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedPoints., m1.supportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedPoints.) && |
| 57 | m.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ticketSupported. == m1.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ticketSupported. && |
| 58 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.sessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionTicket., m1.sessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionTicket.) && |
| 59 | eqSignatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqSignatureAndHashes().(m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes., m1.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes.) && |
| 60 | m.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#secureRenegotiation. == m1.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#secureRenegotiation. && |
| 61 | m.heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatEnabled. == m1.heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatEnabled. && |
| 62 | m.heartbeatModescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatMode. == m1.heartbeatModescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatMode. && |
| 63 | m.extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandomEnabled. == m1.extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandomEnabled. && |
| 64 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandom., m1.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandom.) && |
| 65 | m.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedMasterSecret. == m1.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedMasterSecret. && |
| 66 | eqStringsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqStrings().(m.alpnProtocolsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#alpnProtocols., m1.alpnProtocolsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#alpnProtocols.) && |
| 67 | reflectscip-go gomod github.com/golang/go/src go1.16 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.16 reflect/DeepEqual().(m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions., m1.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions.) |
| 68 | } |
| 69 | |
| 70 | func (m *clientHelloMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#marshal().() []byte { |
| 71 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#raw. != nil { |
| 72 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#raw. |
| 73 | } |
| 74 | |
| 75 | length := 2 + 32 + 1 + len(m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionId.) + 2 + len(m.cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites.)*2 + 1 + len(m.compressionMethodsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#compressionMethods.) |
| 76 | numExtensions := 0 |
| 77 | extensionsLength := 0 |
| 78 | if m.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#nextProtoNeg. { |
| 79 | numExtensions++ |
| 80 | } |
| 81 | if m.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ocspStapling. { |
| 82 | extensionsLength += 1 + 2 + 2 |
| 83 | numExtensions++ |
| 84 | } |
| 85 | if len(m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName.) > 0 { |
| 86 | extensionsLength += 5 + len(m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName.) |
| 87 | numExtensions++ |
| 88 | } |
| 89 | if len(m.supportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedCurves.) > 0 { |
| 90 | extensionsLength += 2 + 2*len(m.supportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedCurves.) |
| 91 | numExtensions++ |
| 92 | } |
| 93 | if len(m.supportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedPoints.) > 0 { |
| 94 | extensionsLength += 1 + len(m.supportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedPoints.) |
| 95 | numExtensions++ |
| 96 | } |
| 97 | if m.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ticketSupported. { |
| 98 | extensionsLength += len(m.sessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionTicket.) |
| 99 | numExtensions++ |
| 100 | } |
| 101 | if len(m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes.) > 0 { |
| 102 | extensionsLength += 2 + 2*len(m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes.) |
| 103 | numExtensions++ |
| 104 | } |
| 105 | if m.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#secureRenegotiation. { |
| 106 | extensionsLength += 1 |
| 107 | numExtensions++ |
| 108 | } |
| 109 | if len(m.alpnProtocolsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#alpnProtocols.) > 0 { |
| 110 | extensionsLength += 2 |
| 111 | for _, s := range m.alpnProtocolsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#alpnProtocols. { |
| 112 | if l := len(s); l == 0 || l > 255 { |
| 113 | panic("invalid ALPN protocol") |
| 114 | } |
| 115 | extensionsLength++ |
| 116 | extensionsLength += len(s) |
| 117 | } |
| 118 | numExtensions++ |
| 119 | } |
| 120 | if m.heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatEnabled. { |
| 121 | extensionsLength += 1 |
| 122 | numExtensions++ |
| 123 | } |
| 124 | if m.extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandomEnabled. { |
| 125 | extensionsLength += 2 + len(m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandom.) |
| 126 | numExtensions++ |
| 127 | } |
| 128 | if m.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedMasterSecret. { |
| 129 | numExtensions++ |
| 130 | } |
| 131 | if m.sctEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sctEnabled. { |
| 132 | numExtensions++ |
| 133 | } |
| 134 | if len(m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions.) > 0 { |
| 135 | // we do not update numExtensions because the extension code and length |
| 136 | // are already contained at the beginning of every 'ext' below |
| 137 | for _, ext := range m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions. { |
| 138 | extensionsLength += len(ext) |
| 139 | } |
| 140 | } |
| 141 | if numExtensions > 0 { |
| 142 | extensionsLength += 4 * numExtensions |
| 143 | length += 2 + extensionsLength |
| 144 | } |
| 145 | |
| 146 | x := make([]byte, 4+length) |
| 147 | x[0] = typeClientHelloscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeClientHello. |
| 148 | x[1] = uint8(length >> 16) |
| 149 | x[2] = uint8(length >> 8) |
| 150 | x[3] = uint8(length) |
| 151 | x[4] = uint8(m.versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#vers. >> 8) |
| 152 | x[5] = uint8(m.versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#vers.) |
| 153 | copy(x[6:38], m.randomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#random.) |
| 154 | x[38] = uint8(len(m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionId.)) |
| 155 | copy(x[39:39+len(m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionId.)], m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionId.) |
| 156 | y := x[39+len(m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionId.):] |
| 157 | // This is a clever way to store the lower 16 bits of 2*len(m.cipherSuites) |
| 158 | y[0] = uint8(len(m.cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites.) >> 7) |
| 159 | y[1] = uint8(len(m.cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites.) << 1) |
| 160 | for i, suite := range m.cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites. { |
| 161 | y[2+i*2] = uint8(suite >> 8) |
| 162 | y[3+i*2] = uint8(suite) |
| 163 | } |
| 164 | z := y[2+len(m.cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites.)*2:] |
| 165 | z[0] = uint8(len(m.compressionMethodsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#compressionMethods.)) |
| 166 | copy(z[1:], m.compressionMethodsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#compressionMethods.) |
| 167 | |
| 168 | z = z[1+len(m.compressionMethodsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#compressionMethods.):] |
| 169 | if numExtensions > 0 || len(m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions.) > 0 { |
| 170 | z[0] = byte(extensionsLength >> 8) |
| 171 | z[1] = byte(extensionsLength) |
| 172 | z = z[2:] |
| 173 | } |
| 174 | if m.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#nextProtoNeg. { |
| 175 | z[0] = byte(extensionNextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionNextProtoNeg. >> 8) |
| 176 | z[1] = byte(extensionNextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionNextProtoNeg. & 0xff) |
| 177 | // The length is always 0 |
| 178 | z = z[4:] |
| 179 | } |
| 180 | if len(m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName.) > 0 { |
| 181 | z[0] = byte(extensionServerNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionServerName. >> 8) |
| 182 | z[1] = byte(extensionServerNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionServerName. & 0xff) |
| 183 | l := len(m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName.) + 5 |
| 184 | z[2] = byte(l >> 8) |
| 185 | z[3] = byte(l) |
| 186 | z = z[4:] |
| 187 | |
| 188 | // RFC 3546, section 3.1 |
| 189 | // |
| 190 | // struct { |
| 191 | // NameType name_type; |
| 192 | // select (name_type) { |
| 193 | // case host_name: HostName; |
| 194 | // } name; |
| 195 | // } ServerName; |
| 196 | // |
| 197 | // enum { |
| 198 | // host_name(0), (255) |
| 199 | // } NameType; |
| 200 | // |
| 201 | // opaque HostName<1..2^16-1>; |
| 202 | // |
| 203 | // struct { |
| 204 | // ServerName server_name_list<1..2^16-1> |
| 205 | // } ServerNameList; |
| 206 | |
| 207 | z[0] = byte((len(m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName.) + 3) >> 8) |
| 208 | z[1] = byte(len(m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName.) + 3) |
| 209 | z[3] = byte(len(m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName.) >> 8) |
| 210 | z[4] = byte(len(m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName.)) |
| 211 | copy(z[5:], []byte(m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName.)) |
| 212 | z = z[l:] |
| 213 | } |
| 214 | if m.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ocspStapling. { |
| 215 | // RFC 4366, section 3.6 |
| 216 | z[0] = byte(extensionStatusRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionStatusRequest. >> 8) |
| 217 | z[1] = byte(extensionStatusRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionStatusRequest.) |
| 218 | z[2] = 0 |
| 219 | z[3] = 5 |
| 220 | z[4] = 1 // OCSP type |
| 221 | // Two zero valued uint16s for the two lengths. |
| 222 | z = z[9:] |
| 223 | } |
| 224 | if len(m.supportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedCurves.) > 0 { |
| 225 | // http://tools.ietf.org/html/rfc4492#section-5.5.1 |
| 226 | z[0] = byte(extensionSupportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSupportedCurves. >> 8) |
| 227 | z[1] = byte(extensionSupportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSupportedCurves.) |
| 228 | l := 2 + 2*len(m.supportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedCurves.) |
| 229 | z[2] = byte(l >> 8) |
| 230 | z[3] = byte(l) |
| 231 | l -= 2 |
| 232 | z[4] = byte(l >> 8) |
| 233 | z[5] = byte(l) |
| 234 | z = z[6:] |
| 235 | for _, curve := range m.supportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedCurves. { |
| 236 | z[0] = byte(curve >> 8) |
| 237 | z[1] = byte(curve) |
| 238 | z = z[2:] |
| 239 | } |
| 240 | } |
| 241 | if len(m.supportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedPoints.) > 0 { |
| 242 | // http://tools.ietf.org/html/rfc4492#section-5.5.2 |
| 243 | z[0] = byte(extensionSupportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSupportedPoints. >> 8) |
| 244 | z[1] = byte(extensionSupportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSupportedPoints.) |
| 245 | l := 1 + len(m.supportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedPoints.) |
| 246 | z[2] = byte(l >> 8) |
| 247 | z[3] = byte(l) |
| 248 | l-- |
| 249 | z[4] = byte(l) |
| 250 | z = z[5:] |
| 251 | for _, pointFormat := range m.supportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedPoints. { |
| 252 | z[0] = byte(pointFormat) |
| 253 | z = z[1:] |
| 254 | } |
| 255 | } |
| 256 | if m.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ticketSupported. { |
| 257 | // http://tools.ietf.org/html/rfc5077#section-3.2 |
| 258 | z[0] = byte(extensionSessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSessionTicket. >> 8) |
| 259 | z[1] = byte(extensionSessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSessionTicket.) |
| 260 | l := len(m.sessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionTicket.) |
| 261 | z[2] = byte(l >> 8) |
| 262 | z[3] = byte(l) |
| 263 | z = z[4:] |
| 264 | copy(z, m.sessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionTicket.) |
| 265 | z = z[len(m.sessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionTicket.):] |
| 266 | } |
| 267 | if len(m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes.) > 0 { |
| 268 | // https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 |
| 269 | z[0] = byte(extensionSignatureAlgorithmsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSignatureAlgorithms. >> 8) |
| 270 | z[1] = byte(extensionSignatureAlgorithmsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSignatureAlgorithms.) |
| 271 | l := 2 + 2*len(m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes.) |
| 272 | z[2] = byte(l >> 8) |
| 273 | z[3] = byte(l) |
| 274 | z = z[4:] |
| 275 | |
| 276 | l -= 2 |
| 277 | z[0] = byte(l >> 8) |
| 278 | z[1] = byte(l) |
| 279 | z = z[2:] |
| 280 | for _, sigAndHash := range m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes. { |
| 281 | z[0] = sigAndHash.Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Hash. |
| 282 | z[1] = sigAndHash.Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Signature. |
| 283 | z = z[2:] |
| 284 | } |
| 285 | } |
| 286 | if m.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#secureRenegotiation. { |
| 287 | z[0] = byte(extensionRenegotiationInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionRenegotiationInfo. >> 8) |
| 288 | z[1] = byte(extensionRenegotiationInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionRenegotiationInfo. & 0xff) |
| 289 | z[2] = 0 |
| 290 | z[3] = 1 |
| 291 | z = z[5:] |
| 292 | } |
| 293 | if len(m.alpnProtocolsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#alpnProtocols.) > 0 { |
| 294 | z[0] = byte(extensionALPNscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionALPN. >> 8) |
| 295 | z[1] = byte(extensionALPNscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionALPN. & 0xff) |
| 296 | lengths := z[2:] |
| 297 | z = z[6:] |
| 298 | |
| 299 | stringsLength := 0 |
| 300 | for _, s := range m.alpnProtocolsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#alpnProtocols. { |
| 301 | l := len(s) |
| 302 | z[0] = byte(l) |
| 303 | copy(z[1:], s) |
| 304 | z = z[1+l:] |
| 305 | stringsLength += 1 + l |
| 306 | } |
| 307 | |
| 308 | lengths[2] = byte(stringsLength >> 8) |
| 309 | lengths[3] = byte(stringsLength) |
| 310 | stringsLength += 2 |
| 311 | lengths[0] = byte(stringsLength >> 8) |
| 312 | lengths[1] = byte(stringsLength) |
| 313 | } |
| 314 | if m.heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatEnabled. { |
| 315 | z[0] = byte(extensionHeartbeatscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionHeartbeat. >> 8) |
| 316 | z[1] = byte(extensionHeartbeatscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionHeartbeat.) |
| 317 | length := 1 |
| 318 | z[2] = byte(length >> 8) |
| 319 | z[3] = byte(length) |
| 320 | z[4] = m.heartbeatModescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatMode. |
| 321 | z = z[5:] |
| 322 | } |
| 323 | if m.extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandomEnabled. { |
| 324 | z[0] = byte(extensionExtendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedRandom. >> 8) |
| 325 | z[1] = byte(extensionExtendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedRandom.) |
| 326 | exLen := len(m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandom.) |
| 327 | length := 2 + exLen |
| 328 | z[2] = byte(length >> 8) |
| 329 | z[3] = byte(length) |
| 330 | z[4] = byte(exLen >> 8) |
| 331 | z[5] = byte(exLen) |
| 332 | z = z[6:] |
| 333 | copy(z, m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandom.) |
| 334 | z = z[exLen:] |
| 335 | } |
| 336 | if m.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedMasterSecret. { |
| 337 | // https://tools.ietf.org/html/draft-ietf-tls-session-hash-01 |
| 338 | z[0] = byte(extensionExtendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedMasterSecret. >> 8) |
| 339 | z[1] = byte(extensionExtendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedMasterSecret. & 0xff) |
| 340 | z = z[4:] |
| 341 | } |
| 342 | if m.sctEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sctEnabled. { |
| 343 | // https://tools.ietf.org/html/rfc6962#section-3.3.1 |
| 344 | z[0] = byte(extensionSCTscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSCT. >> 8) |
| 345 | z[1] = byte(extensionSCTscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSCT.) |
| 346 | // zero uint16 for the zero-length extension_data |
| 347 | z = z[4:] |
| 348 | } |
| 349 | if len(m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions.) > 0 { |
| 350 | for _, ext := range m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions. { |
| 351 | copy(z, ext) |
| 352 | z = z[len(ext):] |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#raw. = x |
| 357 | |
| 358 | return x |
| 359 | } |
| 360 | |
| 361 | func (m *clientHelloMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unmarshal().(data []byte) bool { |
| 362 | if len(data) < 42 { |
| 363 | return false |
| 364 | } |
| 365 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#raw. = data |
| 366 | m.versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#vers. = uint16(data[4])<<8 | uint16(data[5]) |
| 367 | m.randomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#random. = data[6:38] |
| 368 | sessionIdLen := int(data[38]) |
| 369 | if sessionIdLen > 32 || len(data) < 39+sessionIdLen { |
| 370 | return false |
| 371 | } |
| 372 | m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionId. = data[39 : 39+sessionIdLen] |
| 373 | data = data[39+sessionIdLen:] |
| 374 | if len(data) < 2 { |
| 375 | return false |
| 376 | } |
| 377 | // cipherSuiteLen is the number of bytes of cipher suite numbers. Since |
| 378 | // they are uint16s, the number must be even. |
| 379 | cipherSuiteLen := int(data[0])<<8 | int(data[1]) |
| 380 | if cipherSuiteLen%2 == 1 || len(data) < 2+cipherSuiteLen { |
| 381 | return false |
| 382 | } |
| 383 | numCipherSuites := cipherSuiteLen / 2 |
| 384 | m.cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites. = make([]uint16, numCipherSuites) |
| 385 | for i := 0; i < numCipherSuites; i++ { |
| 386 | m.cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites.[i] = uint16(data[2+2*i])<<8 | uint16(data[3+2*i]) |
| 387 | if m.cipherSuitesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#cipherSuites.[i] == scsvRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/scsvRenegotiation. { |
| 388 | m.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#secureRenegotiation. = true |
| 389 | } |
| 390 | } |
| 391 | data = data[2+cipherSuiteLen:] |
| 392 | if len(data) < 1 { |
| 393 | return false |
| 394 | } |
| 395 | compressionMethodsLen := int(data[0]) |
| 396 | if len(data) < 1+compressionMethodsLen { |
| 397 | return false |
| 398 | } |
| 399 | m.compressionMethodsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#compressionMethods. = data[1 : 1+compressionMethodsLen] |
| 400 | |
| 401 | data = data[1+compressionMethodsLen:] |
| 402 | |
| 403 | m.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#nextProtoNeg. = false |
| 404 | m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName. = "" |
| 405 | m.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ocspStapling. = false |
| 406 | m.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ticketSupported. = false |
| 407 | m.sessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionTicket. = nil |
| 408 | m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes. = nil |
| 409 | m.heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatEnabled. = false |
| 410 | m.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedMasterSecret. = false |
| 411 | m.alpnProtocolsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#alpnProtocols. = nil |
| 412 | m.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#scts. = false |
| 413 | m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions. = [][]byte(nil) |
| 414 | |
| 415 | if len(data) == 0 { |
| 416 | // ClientHello is optionally followed by extension data |
| 417 | return true |
| 418 | } |
| 419 | if len(data) < 2 { |
| 420 | return false |
| 421 | } |
| 422 | |
| 423 | extensionsLength := int(data[0])<<8 | int(data[1]) |
| 424 | data = data[2:] |
| 425 | if extensionsLength != len(data) { |
| 426 | return false |
| 427 | } |
| 428 | |
| 429 | for len(data) != 0 { |
| 430 | if len(data) < 4 { |
| 431 | return false |
| 432 | } |
| 433 | fullData := data |
| 434 | extension := uint16(data[0])<<8 | uint16(data[1]) |
| 435 | length := int(data[2])<<8 | int(data[3]) |
| 436 | data = data[4:] |
| 437 | if len(data) < length { |
| 438 | return false |
| 439 | } |
| 440 | |
| 441 | switch extension { |
| 442 | case extensionServerNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionServerName.: |
| 443 | // we keep only the last name for m.serverName |
| 444 | if length < 2 { |
| 445 | return false |
| 446 | } |
| 447 | numNames := int(data[0])<<8 | int(data[1]) |
| 448 | d := data[2:] |
| 449 | for i := 0; i < numNames; i++ { |
| 450 | if len(d) < 3 { |
| 451 | return false |
| 452 | } |
| 453 | nameType := d[0] |
| 454 | nameLen := int(d[1])<<8 | int(d[2]) |
| 455 | d = d[3:] |
| 456 | if len(d) < nameLen { |
| 457 | return false |
| 458 | } |
| 459 | if nameType == 0 { |
| 460 | m.serverNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#serverName. = string(d[0:nameLen]) |
| 461 | break |
| 462 | } |
| 463 | d = d[nameLen:] |
| 464 | } |
| 465 | case extensionNextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionNextProtoNeg.: |
| 466 | if length > 0 { |
| 467 | return false |
| 468 | } |
| 469 | m.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#nextProtoNeg. = true |
| 470 | case extensionStatusRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionStatusRequest.: |
| 471 | m.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ocspStapling. = length > 0 && data[0] == statusTypeOCSPscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/statusTypeOCSP. |
| 472 | case extensionSupportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSupportedCurves.: |
| 473 | // http://tools.ietf.org/html/rfc4492#section-5.5.1 |
| 474 | if length < 2 { |
| 475 | return false |
| 476 | } |
| 477 | l := int(data[0])<<8 | int(data[1]) |
| 478 | if l%2 == 1 || length != l+2 { |
| 479 | return false |
| 480 | } |
| 481 | numCurves := l / 2 |
| 482 | m.supportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedCurves. = make([]CurveIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/CurveID#, numCurves) |
| 483 | d := data[2:] |
| 484 | for i := 0; i < numCurves; i++ { |
| 485 | m.supportedCurvesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedCurves.[i] = CurveIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/CurveID#(d[0])<<8 | CurveIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/CurveID#(d[1]) |
| 486 | d = d[2:] |
| 487 | } |
| 488 | case extensionSupportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSupportedPoints.: |
| 489 | // http://tools.ietf.org/html/rfc4492#section-5.5.2 |
| 490 | if length < 1 { |
| 491 | return false |
| 492 | } |
| 493 | l := int(data[0]) |
| 494 | if length != l+1 { |
| 495 | return false |
| 496 | } |
| 497 | m.supportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedPoints. = make([]uint8, l) |
| 498 | copy(m.supportedPointsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#supportedPoints., data[1:]) |
| 499 | case extensionSessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSessionTicket.: |
| 500 | // http://tools.ietf.org/html/rfc5077#section-3.2 |
| 501 | m.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#ticketSupported. = true |
| 502 | m.sessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#sessionTicket. = data[:length] |
| 503 | case extensionSignatureAlgorithmsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSignatureAlgorithms.: |
| 504 | // https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 |
| 505 | if length < 2 || length&1 != 0 { |
| 506 | return false |
| 507 | } |
| 508 | l := int(data[0])<<8 | int(data[1]) |
| 509 | if l != length-2 { |
| 510 | return false |
| 511 | } |
| 512 | n := l / 2 |
| 513 | d := data[2:] |
| 514 | m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes. = make([]SigAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#, n) |
| 515 | for i := range m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes. { |
| 516 | m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes.[i].Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Hash. = d[0] |
| 517 | m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#signatureAndHashes.[i].Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Signature. = d[1] |
| 518 | d = d[2:] |
| 519 | } |
| 520 | case extensionRenegotiationInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionRenegotiationInfo.: |
| 521 | if length != 1 || data[0] != 0 { |
| 522 | return false |
| 523 | } |
| 524 | m.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#secureRenegotiation. = true |
| 525 | case extensionALPNscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionALPN.: |
| 526 | if length < 2 { |
| 527 | return false |
| 528 | } |
| 529 | l := int(data[0])<<8 | int(data[1]) |
| 530 | if l != length-2 { |
| 531 | return false |
| 532 | } |
| 533 | d := data[2:length] |
| 534 | for len(d) != 0 { |
| 535 | stringLen := int(d[0]) |
| 536 | d = d[1:] |
| 537 | if stringLen == 0 || stringLen > len(d) { |
| 538 | return false |
| 539 | } |
| 540 | m.alpnProtocolsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#alpnProtocols. = append(m.alpnProtocolsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#alpnProtocols., string(d[:stringLen])) |
| 541 | d = d[stringLen:] |
| 542 | } |
| 543 | case extensionHeartbeatscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionHeartbeat.: |
| 544 | // https://tools.ietf.org/html/rfc6520 |
| 545 | if length != 1 { |
| 546 | return false |
| 547 | } |
| 548 | mode := data[0] |
| 549 | if mode != heartbeatModePeerAllowedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/heartbeatModePeerAllowed. && |
| 550 | mode != heartbeatModePeerNotAllowedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/heartbeatModePeerNotAllowed. { |
| 551 | return false |
| 552 | } |
| 553 | m.heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatEnabled. = true |
| 554 | m.heartbeatModescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#heartbeatMode. = mode |
| 555 | case extensionExtendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedRandom.: |
| 556 | if length < 3 { |
| 557 | return false |
| 558 | } |
| 559 | exLen := int(data[0])<<8 | int(data[1]) |
| 560 | if length != exLen+2 { |
| 561 | return false |
| 562 | } |
| 563 | if exLen > len(data) { |
| 564 | return false |
| 565 | } |
| 566 | m.extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandomEnabled. = true |
| 567 | m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandom. = make([]byte, exLen) |
| 568 | copy(m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedRandom., data[2:]) |
| 569 | case extensionExtendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedMasterSecret.: |
| 570 | if length != 0 { |
| 571 | return false |
| 572 | } |
| 573 | m.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#extendedMasterSecret. = true |
| 574 | case extensionSCTscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSCT.: |
| 575 | m.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#scts. = true |
| 576 | if length != 0 { |
| 577 | return false |
| 578 | } |
| 579 | default: |
| 580 | fullExt := append(fullData[:4], data[:length]...) |
| 581 | m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions. = append(m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientHelloMsg#unknownExtensions., fullExt) |
| 582 | } |
| 583 | data = data[length:] |
| 584 | } |
| 585 | |
| 586 | return true |
| 587 | } |
| 588 | |
| 589 | type serverHelloMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg# struct { |
| 590 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#raw. []byte |
| 591 | versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#vers. uint16 |
| 592 | randomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#random. []byte |
| 593 | sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#sessionId. []byte |
| 594 | cipherSuitescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#cipherSuite. uint16 |
| 595 | compressionMethodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#compressionMethod. uint8 |
| 596 | nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtoNeg. bool |
| 597 | nextProtosscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtos. []string |
| 598 | ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ocspStapling. bool |
| 599 | sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#scts. [][]byte |
| 600 | ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ticketSupported. bool |
| 601 | secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#secureRenegotiation. bool |
| 602 | heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#heartbeatEnabled. bool |
| 603 | heartbeatModescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#heartbeatMode. uint8 |
| 604 | extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandomEnabled. bool |
| 605 | extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandom. []byte |
| 606 | extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedMasterSecret. bool |
| 607 | alpnProtocolscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#alpnProtocol. string |
| 608 | unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions. [][]byte |
| 609 | } |
| 610 | |
| 611 | func (m *serverHelloMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#equal().(i interface{}) bool { |
| 612 | m1, ok := i.(*serverHelloMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#) |
| 613 | if !ok { |
| 614 | return false |
| 615 | } |
| 616 | |
| 617 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#raw.) && |
| 618 | m.versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#vers. == m1.versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#vers. && |
| 619 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.randomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#random., m1.randomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#random.) && |
| 620 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#sessionId., m1.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#sessionId.) && |
| 621 | m.cipherSuitescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#cipherSuite. == m1.cipherSuitescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#cipherSuite. && |
| 622 | m.compressionMethodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#compressionMethod. == m1.compressionMethodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#compressionMethod. && |
| 623 | m.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtoNeg. == m1.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtoNeg. && |
| 624 | eqStringsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqStrings().(m.nextProtosscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtos., m1.nextProtosscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtos.) && |
| 625 | m.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ocspStapling. == m1.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ocspStapling. && |
| 626 | m.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ticketSupported. == m1.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ticketSupported. && |
| 627 | m.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#secureRenegotiation. == m1.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#secureRenegotiation. && |
| 628 | m.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedMasterSecret. == m1.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedMasterSecret. && |
| 629 | m.alpnProtocolscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#alpnProtocol. == m1.alpnProtocolscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#alpnProtocol. && |
| 630 | reflectscip-go gomod github.com/golang/go/src go1.16 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.16 reflect/DeepEqual().(m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions., m1.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions.) |
| 631 | } |
| 632 | |
| 633 | func (m *serverHelloMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#marshal().() []byte { |
| 634 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#raw. != nil { |
| 635 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#raw. |
| 636 | } |
| 637 | |
| 638 | length := 38 + len(m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#sessionId.) |
| 639 | numExtensions := 0 |
| 640 | extensionsLength := 0 |
| 641 | |
| 642 | nextProtoLen := 0 |
| 643 | if m.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtoNeg. { |
| 644 | numExtensions++ |
| 645 | for _, v := range m.nextProtosscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtos. { |
| 646 | nextProtoLen += len(v) |
| 647 | } |
| 648 | nextProtoLen += len(m.nextProtosscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtos.) |
| 649 | extensionsLength += nextProtoLen |
| 650 | } |
| 651 | if m.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ocspStapling. { |
| 652 | numExtensions++ |
| 653 | } |
| 654 | if m.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ticketSupported. { |
| 655 | numExtensions++ |
| 656 | } |
| 657 | if m.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#secureRenegotiation. { |
| 658 | extensionsLength += 1 |
| 659 | numExtensions++ |
| 660 | } |
| 661 | if alpnLen := len(m.alpnProtocolscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#alpnProtocol.); alpnLen > 0 { |
| 662 | if alpnLen >= 256 { |
| 663 | panic("invalid ALPN protocol") |
| 664 | } |
| 665 | extensionsLength += 2 + 1 + alpnLen |
| 666 | numExtensions++ |
| 667 | } |
| 668 | if m.heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#heartbeatEnabled. { |
| 669 | extensionsLength += 1 |
| 670 | numExtensions++ |
| 671 | } |
| 672 | if m.extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandomEnabled. { |
| 673 | extensionsLength += 2 + len(m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandom.) |
| 674 | numExtensions++ |
| 675 | } |
| 676 | if m.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedMasterSecret. { |
| 677 | numExtensions++ |
| 678 | } |
| 679 | sctLen := 0 |
| 680 | if len(m.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#scts.) > 0 { |
| 681 | for _, sct := range m.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#scts. { |
| 682 | sctLen += len(sct) + 2 |
| 683 | } |
| 684 | extensionsLength += 2 + sctLen |
| 685 | numExtensions++ |
| 686 | } |
| 687 | if len(m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions.) > 0 { |
| 688 | // we do not update numExtensions because the extension code and length |
| 689 | // are already contained at the beginning of every 'ext' below |
| 690 | for _, ext := range m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions. { |
| 691 | extensionsLength += len(ext) |
| 692 | } |
| 693 | } |
| 694 | if numExtensions > 0 { |
| 695 | extensionsLength += 4 * numExtensions |
| 696 | length += 2 + extensionsLength |
| 697 | } |
| 698 | |
| 699 | x := make([]byte, 4+length) |
| 700 | x[0] = typeServerHelloscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeServerHello. |
| 701 | x[1] = uint8(length >> 16) |
| 702 | x[2] = uint8(length >> 8) |
| 703 | x[3] = uint8(length) |
| 704 | x[4] = uint8(m.versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#vers. >> 8) |
| 705 | x[5] = uint8(m.versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#vers.) |
| 706 | copy(x[6:38], m.randomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#random.) |
| 707 | x[38] = uint8(len(m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#sessionId.)) |
| 708 | copy(x[39:39+len(m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#sessionId.)], m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#sessionId.) |
| 709 | z := x[39+len(m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#sessionId.):] |
| 710 | z[0] = uint8(m.cipherSuitescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#cipherSuite. >> 8) |
| 711 | z[1] = uint8(m.cipherSuitescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#cipherSuite.) |
| 712 | z[2] = uint8(m.compressionMethodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#compressionMethod.) |
| 713 | |
| 714 | z = z[3:] |
| 715 | if numExtensions > 0 || len(m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions.) > 0 { |
| 716 | z[0] = byte(extensionsLength >> 8) |
| 717 | z[1] = byte(extensionsLength) |
| 718 | z = z[2:] |
| 719 | } |
| 720 | if m.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtoNeg. { |
| 721 | z[0] = byte(extensionNextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionNextProtoNeg. >> 8) |
| 722 | z[1] = byte(extensionNextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionNextProtoNeg. & 0xff) |
| 723 | z[2] = byte(nextProtoLen >> 8) |
| 724 | z[3] = byte(nextProtoLen) |
| 725 | z = z[4:] |
| 726 | |
| 727 | for _, v := range m.nextProtosscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtos. { |
| 728 | l := len(v) |
| 729 | if l > 255 { |
| 730 | l = 255 |
| 731 | } |
| 732 | z[0] = byte(l) |
| 733 | copy(z[1:], []byte(v[0:l])) |
| 734 | z = z[1+l:] |
| 735 | } |
| 736 | } |
| 737 | if m.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ocspStapling. { |
| 738 | z[0] = byte(extensionStatusRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionStatusRequest. >> 8) |
| 739 | z[1] = byte(extensionStatusRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionStatusRequest.) |
| 740 | z = z[4:] |
| 741 | } |
| 742 | if m.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ticketSupported. { |
| 743 | z[0] = byte(extensionSessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSessionTicket. >> 8) |
| 744 | z[1] = byte(extensionSessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSessionTicket.) |
| 745 | z = z[4:] |
| 746 | } |
| 747 | if m.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#secureRenegotiation. { |
| 748 | z[0] = byte(extensionRenegotiationInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionRenegotiationInfo. >> 8) |
| 749 | z[1] = byte(extensionRenegotiationInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionRenegotiationInfo. & 0xff) |
| 750 | z[2] = 0 |
| 751 | z[3] = 1 |
| 752 | z = z[5:] |
| 753 | } |
| 754 | if alpnLen := len(m.alpnProtocolscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#alpnProtocol.); alpnLen > 0 { |
| 755 | z[0] = byte(extensionALPNscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionALPN. >> 8) |
| 756 | z[1] = byte(extensionALPNscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionALPN. & 0xff) |
| 757 | l := 2 + 1 + alpnLen |
| 758 | z[2] = byte(l >> 8) |
| 759 | z[3] = byte(l) |
| 760 | l -= 2 |
| 761 | z[4] = byte(l >> 8) |
| 762 | z[5] = byte(l) |
| 763 | l -= 1 |
| 764 | z[6] = byte(l) |
| 765 | copy(z[7:], []byte(m.alpnProtocolscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#alpnProtocol.)) |
| 766 | z = z[7+alpnLen:] |
| 767 | } |
| 768 | if m.heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#heartbeatEnabled. { |
| 769 | z[0] = byte(extensionHeartbeatscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionHeartbeat. >> 8) |
| 770 | z[1] = byte(extensionHeartbeatscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionHeartbeat.) |
| 771 | z[2] = byte(1 >> 8) |
| 772 | z[3] = byte(1) |
| 773 | z[4] = m.heartbeatModescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#heartbeatMode. |
| 774 | z = z[5:] |
| 775 | } |
| 776 | if m.extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandomEnabled. { |
| 777 | z[0] = byte(extensionExtendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedRandom. >> 8) |
| 778 | z[1] = byte(extensionExtendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedRandom.) |
| 779 | exLen := len(m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandom.) |
| 780 | fullLength := 2 + exLen |
| 781 | z[2] = byte(fullLength << 8) |
| 782 | z[3] = byte(fullLength) |
| 783 | z[4] = byte(exLen << 8) |
| 784 | z[5] = byte(exLen) |
| 785 | z = z[6:] |
| 786 | copy(z, m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandom.) |
| 787 | z = z[exLen:] |
| 788 | } |
| 789 | if m.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedMasterSecret. { |
| 790 | z[0] = byte(extensionExtendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedMasterSecret. >> 8) |
| 791 | z[1] = byte(extensionExtendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedMasterSecret. & 0xff) |
| 792 | z = z[4:] |
| 793 | } |
| 794 | if sctLen > 0 { |
| 795 | z[0] = byte(extensionSCTscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSCT. >> 8) |
| 796 | z[1] = byte(extensionSCTscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSCT.) |
| 797 | l := sctLen + 2 |
| 798 | z[2] = byte(l >> 8) |
| 799 | z[3] = byte(l) |
| 800 | z[4] = byte(sctLen >> 8) |
| 801 | z[5] = byte(sctLen) |
| 802 | |
| 803 | z = z[6:] |
| 804 | for _, sct := range m.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#scts. { |
| 805 | z[0] = byte(len(sct) >> 8) |
| 806 | z[1] = byte(len(sct)) |
| 807 | copy(z[2:], sct) |
| 808 | z = z[len(sct)+2:] |
| 809 | } |
| 810 | } |
| 811 | if len(m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions.) > 0 { |
| 812 | for _, ext := range m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions. { |
| 813 | copy(z, ext) |
| 814 | z = z[len(ext):] |
| 815 | } |
| 816 | } |
| 817 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#raw. = x |
| 818 | return x |
| 819 | } |
| 820 | |
| 821 | func (m *serverHelloMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unmarshal().(data []byte) bool { |
| 822 | if len(data) < 42 { |
| 823 | return false |
| 824 | } |
| 825 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#raw. = data |
| 826 | m.versscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#vers. = uint16(data[4])<<8 | uint16(data[5]) |
| 827 | m.randomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#random. = data[6:38] |
| 828 | sessionIdLen := int(data[38]) |
| 829 | if sessionIdLen > 32 || len(data) < 39+sessionIdLen { |
| 830 | return false |
| 831 | } |
| 832 | m.sessionIdscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#sessionId. = data[39 : 39+sessionIdLen] |
| 833 | data = data[39+sessionIdLen:] |
| 834 | if len(data) < 3 { |
| 835 | return false |
| 836 | } |
| 837 | m.cipherSuitescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#cipherSuite. = uint16(data[0])<<8 | uint16(data[1]) |
| 838 | m.compressionMethodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#compressionMethod. = data[2] |
| 839 | data = data[3:] |
| 840 | |
| 841 | m.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtoNeg. = false |
| 842 | m.nextProtosscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtos. = nil |
| 843 | m.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#scts. = nil |
| 844 | m.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ocspStapling. = false |
| 845 | m.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ticketSupported. = false |
| 846 | m.heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#heartbeatEnabled. = false |
| 847 | m.extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandomEnabled. = false |
| 848 | m.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedMasterSecret. = false |
| 849 | m.alpnProtocolscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#alpnProtocol. = "" |
| 850 | m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions. = [][]byte(nil) |
| 851 | |
| 852 | if len(data) == 0 { |
| 853 | // ServerHello is optionally followed by extension data |
| 854 | return true |
| 855 | } |
| 856 | if len(data) < 2 { |
| 857 | return false |
| 858 | } |
| 859 | |
| 860 | extensionsLength := int(data[0])<<8 | int(data[1]) |
| 861 | data = data[2:] |
| 862 | if len(data) != extensionsLength { |
| 863 | return false |
| 864 | } |
| 865 | |
| 866 | for len(data) != 0 { |
| 867 | if len(data) < 4 { |
| 868 | return false |
| 869 | } |
| 870 | fullData := data |
| 871 | extension := uint16(data[0])<<8 | uint16(data[1]) |
| 872 | length := int(data[2])<<8 | int(data[3]) |
| 873 | data = data[4:] |
| 874 | if len(data) < length { |
| 875 | return false |
| 876 | } |
| 877 | |
| 878 | switch extension { |
| 879 | case extensionNextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionNextProtoNeg.: |
| 880 | m.nextProtoNegscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtoNeg. = true |
| 881 | d := data[:length] |
| 882 | for len(d) > 0 { |
| 883 | l := int(d[0]) |
| 884 | d = d[1:] |
| 885 | if l == 0 || l > len(d) { |
| 886 | return false |
| 887 | } |
| 888 | m.nextProtosscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtos. = append(m.nextProtosscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#nextProtos., string(d[:l])) |
| 889 | d = d[l:] |
| 890 | } |
| 891 | case extensionStatusRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionStatusRequest.: |
| 892 | if length > 0 { |
| 893 | return false |
| 894 | } |
| 895 | m.ocspStaplingscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ocspStapling. = true |
| 896 | case extensionSessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSessionTicket.: |
| 897 | if length > 0 { |
| 898 | return false |
| 899 | } |
| 900 | m.ticketSupportedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#ticketSupported. = true |
| 901 | case extensionRenegotiationInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionRenegotiationInfo.: |
| 902 | if length != 1 || data[0] != 0 { |
| 903 | return false |
| 904 | } |
| 905 | m.secureRenegotiationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#secureRenegotiation. = true |
| 906 | case extensionALPNscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionALPN.: |
| 907 | d := data[:length] |
| 908 | if len(d) < 3 { |
| 909 | return false |
| 910 | } |
| 911 | l := int(d[0])<<8 | int(d[1]) |
| 912 | if l != len(d)-2 { |
| 913 | return false |
| 914 | } |
| 915 | d = d[2:] |
| 916 | l = int(d[0]) |
| 917 | if l != len(d)-1 { |
| 918 | return false |
| 919 | } |
| 920 | d = d[1:] |
| 921 | if len(d) == 0 { |
| 922 | // ALPN protocols must not be empty. |
| 923 | return false |
| 924 | } |
| 925 | m.alpnProtocolscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#alpnProtocol. = string(d) |
| 926 | case extensionHeartbeatscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionHeartbeat.: |
| 927 | m.heartbeatEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#heartbeatEnabled. = true |
| 928 | m.heartbeatModescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#heartbeatMode. = data[0] |
| 929 | case extensionExtendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedRandom.: |
| 930 | m.extendedRandomEnabledscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandomEnabled. = true |
| 931 | if length < 3 { |
| 932 | return false |
| 933 | } |
| 934 | exRandLen := int(data[0])<<8 | int(data[1]) |
| 935 | if length != exRandLen+2 { |
| 936 | return false |
| 937 | } |
| 938 | exRand := data[2:] |
| 939 | if len(exRand) < exRandLen { |
| 940 | return false |
| 941 | } |
| 942 | m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandom. = make([]byte, exRandLen) |
| 943 | copy(m.extendedRandomscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedRandom., data[2:]) |
| 944 | case extensionExtendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionExtendedMasterSecret.: |
| 945 | if length != 0 { |
| 946 | return false |
| 947 | } |
| 948 | m.extendedMasterSecretscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#extendedMasterSecret. = true |
| 949 | |
| 950 | case extensionSCTscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/extensionSCT.: |
| 951 | d := data[:length] |
| 952 | if len(d) < 2 { |
| 953 | return false |
| 954 | } |
| 955 | l := int(d[0])<<8 | int(d[1]) |
| 956 | d = d[2:] |
| 957 | if len(d) != l || l == 0 { |
| 958 | return false |
| 959 | } |
| 960 | m.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#scts. = make([][]byte, 0, 3) |
| 961 | for len(d) != 0 { |
| 962 | if len(d) < 2 { |
| 963 | return false |
| 964 | } |
| 965 | sctLen := int(d[0])<<8 | int(d[1]) |
| 966 | d = d[2:] |
| 967 | if sctLen == 0 || len(d) < sctLen { |
| 968 | return false |
| 969 | } |
| 970 | m.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#scts. = append(m.sctsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#scts., d[:sctLen]) |
| 971 | d = d[sctLen:] |
| 972 | } |
| 973 | default: |
| 974 | fullExt := append(fullData[:4], data[:length]...) |
| 975 | m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions. = append(m.unknownExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloMsg#unknownExtensions., fullExt) |
| 976 | } |
| 977 | data = data[length:] |
| 978 | } |
| 979 | |
| 980 | return true |
| 981 | } |
| 982 | |
| 983 | type certificateMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg# struct { |
| 984 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#raw. []byte |
| 985 | certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#certificates. [][]byte |
| 986 | } |
| 987 | |
| 988 | func (m *certificateMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#equal().(i interface{}) bool { |
| 989 | m1, ok := i.(*certificateMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#) |
| 990 | if !ok { |
| 991 | return false |
| 992 | } |
| 993 | |
| 994 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#raw.) && |
| 995 | eqByteSlicesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqByteSlices().(m.certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#certificates., m1.certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#certificates.) |
| 996 | } |
| 997 | |
| 998 | func (m *certificateMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#marshal().() (x []byte) { |
| 999 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#raw. != nil { |
| 1000 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#raw. |
| 1001 | } |
| 1002 | |
| 1003 | var i int |
| 1004 | for _, slice := range m.certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#certificates. { |
| 1005 | i += len(slice) |
| 1006 | } |
| 1007 | |
| 1008 | length := 3 + 3*len(m.certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#certificates.) + i |
| 1009 | x = make([]byte, 4+length) |
| 1010 | x[0] = typeCertificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeCertificate. |
| 1011 | x[1] = uint8(length >> 16) |
| 1012 | x[2] = uint8(length >> 8) |
| 1013 | x[3] = uint8(length) |
| 1014 | |
| 1015 | certificateOctets := length - 3 |
| 1016 | x[4] = uint8(certificateOctets >> 16) |
| 1017 | x[5] = uint8(certificateOctets >> 8) |
| 1018 | x[6] = uint8(certificateOctets) |
| 1019 | |
| 1020 | y := x[7:] |
| 1021 | for _, slice := range m.certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#certificates. { |
| 1022 | y[0] = uint8(len(slice) >> 16) |
| 1023 | y[1] = uint8(len(slice) >> 8) |
| 1024 | y[2] = uint8(len(slice)) |
| 1025 | copy(y[3:], slice) |
| 1026 | y = y[3+len(slice):] |
| 1027 | } |
| 1028 | |
| 1029 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#raw. = x |
| 1030 | return |
| 1031 | } |
| 1032 | |
| 1033 | func (m *certificateMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#unmarshal().(data []byte) bool { |
| 1034 | if len(data) < 7 { |
| 1035 | return false |
| 1036 | } |
| 1037 | |
| 1038 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#raw. = data |
| 1039 | certsLen := uint32(data[4])<<16 | uint32(data[5])<<8 | uint32(data[6]) |
| 1040 | if uint32(len(data)) != certsLen+7 { |
| 1041 | return false |
| 1042 | } |
| 1043 | |
| 1044 | numCerts := 0 |
| 1045 | d := data[7:] |
| 1046 | for certsLen > 0 { |
| 1047 | if len(d) < 4 { |
| 1048 | return false |
| 1049 | } |
| 1050 | certLen := uint32(d[0])<<16 | uint32(d[1])<<8 | uint32(d[2]) |
| 1051 | if uint32(len(d)) < 3+certLen { |
| 1052 | return false |
| 1053 | } |
| 1054 | d = d[3+certLen:] |
| 1055 | certsLen -= 3 + certLen |
| 1056 | numCerts++ |
| 1057 | } |
| 1058 | |
| 1059 | m.certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#certificates. = make([][]byte, numCerts) |
| 1060 | d = data[7:] |
| 1061 | for i := 0; i < numCerts; i++ { |
| 1062 | certLen := uint32(d[0])<<16 | uint32(d[1])<<8 | uint32(d[2]) |
| 1063 | m.certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateMsg#certificates.[i] = d[3 : 3+certLen] |
| 1064 | d = d[3+certLen:] |
| 1065 | } |
| 1066 | |
| 1067 | return true |
| 1068 | } |
| 1069 | |
| 1070 | type serverKeyExchangeMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg# struct { |
| 1071 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#raw. []byte |
| 1072 | digestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#digest. []byte |
| 1073 | keyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#key. []byte |
| 1074 | } |
| 1075 | |
| 1076 | func (m *serverKeyExchangeMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#equal().(i interface{}) bool { |
| 1077 | m1, ok := i.(*serverKeyExchangeMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#) |
| 1078 | if !ok { |
| 1079 | return false |
| 1080 | } |
| 1081 | |
| 1082 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#raw.) && |
| 1083 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.keyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#key., m1.keyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#key.) |
| 1084 | } |
| 1085 | |
| 1086 | func (m *serverKeyExchangeMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#marshal().() []byte { |
| 1087 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#raw. != nil { |
| 1088 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#raw. |
| 1089 | } |
| 1090 | length := len(m.keyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#key.) |
| 1091 | x := make([]byte, length+4) |
| 1092 | x[0] = typeServerKeyExchangescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeServerKeyExchange. |
| 1093 | x[1] = uint8(length >> 16) |
| 1094 | x[2] = uint8(length >> 8) |
| 1095 | x[3] = uint8(length) |
| 1096 | copy(x[4:], m.keyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#key.) |
| 1097 | |
| 1098 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#raw. = x |
| 1099 | return x |
| 1100 | } |
| 1101 | |
| 1102 | func (m *serverKeyExchangeMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#unmarshal().(data []byte) bool { |
| 1103 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#raw. = data |
| 1104 | if len(data) < 4 { |
| 1105 | return false |
| 1106 | } |
| 1107 | m.keyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverKeyExchangeMsg#key. = data[4:] |
| 1108 | return true |
| 1109 | } |
| 1110 | |
| 1111 | type certificateStatusMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg# struct { |
| 1112 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#raw. []byte |
| 1113 | statusTypescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#statusType. uint8 |
| 1114 | responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#response. []byte |
| 1115 | } |
| 1116 | |
| 1117 | func (m *certificateStatusMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#equal().(i interface{}) bool { |
| 1118 | m1, ok := i.(*certificateStatusMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#) |
| 1119 | if !ok { |
| 1120 | return false |
| 1121 | } |
| 1122 | |
| 1123 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#raw.) && |
| 1124 | m.statusTypescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#statusType. == m1.statusTypescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#statusType. && |
| 1125 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#response., m1.responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#response.) |
| 1126 | } |
| 1127 | |
| 1128 | func (m *certificateStatusMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#marshal().() []byte { |
| 1129 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#raw. != nil { |
| 1130 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#raw. |
| 1131 | } |
| 1132 | |
| 1133 | var x []byte |
| 1134 | if m.statusTypescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#statusType. == statusTypeOCSPscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/statusTypeOCSP. { |
| 1135 | x = make([]byte, 4+4+len(m.responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#response.)) |
| 1136 | x[0] = typeCertificateStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeCertificateStatus. |
| 1137 | l := len(m.responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#response.) + 4 |
| 1138 | x[1] = byte(l >> 16) |
| 1139 | x[2] = byte(l >> 8) |
| 1140 | x[3] = byte(l) |
| 1141 | x[4] = statusTypeOCSPscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/statusTypeOCSP. |
| 1142 | |
| 1143 | l -= 4 |
| 1144 | x[5] = byte(l >> 16) |
| 1145 | x[6] = byte(l >> 8) |
| 1146 | x[7] = byte(l) |
| 1147 | copy(x[8:], m.responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#response.) |
| 1148 | } else { |
| 1149 | x = []byte{typeCertificateStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeCertificateStatus., 0, 0, 1, m.statusTypescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#statusType.} |
| 1150 | } |
| 1151 | |
| 1152 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#raw. = x |
| 1153 | return x |
| 1154 | } |
| 1155 | |
| 1156 | func (m *certificateStatusMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#unmarshal().(data []byte) bool { |
| 1157 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#raw. = data |
| 1158 | if len(data) < 5 { |
| 1159 | return false |
| 1160 | } |
| 1161 | m.statusTypescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#statusType. = data[4] |
| 1162 | |
| 1163 | m.responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#response. = nil |
| 1164 | if m.statusTypescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#statusType. == statusTypeOCSPscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/statusTypeOCSP. { |
| 1165 | if len(data) < 8 { |
| 1166 | return false |
| 1167 | } |
| 1168 | respLen := uint32(data[5])<<16 | uint32(data[6])<<8 | uint32(data[7]) |
| 1169 | if uint32(len(data)) != 4+4+respLen { |
| 1170 | return false |
| 1171 | } |
| 1172 | m.responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateStatusMsg#response. = data[8:] |
| 1173 | } |
| 1174 | return true |
| 1175 | } |
| 1176 | |
| 1177 | type serverHelloDoneMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloDoneMsg# struct{} |
| 1178 | |
| 1179 | func (m *serverHelloDoneMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloDoneMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloDoneMsg#equal().(i interface{}) bool { |
| 1180 | _, ok := i.(*serverHelloDoneMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloDoneMsg#) |
| 1181 | return ok |
| 1182 | } |
| 1183 | |
| 1184 | func (m *serverHelloDoneMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloDoneMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloDoneMsg#marshal().() []byte { |
| 1185 | x := make([]byte, 4) |
| 1186 | x[0] = typeServerHelloDonescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeServerHelloDone. |
| 1187 | return x |
| 1188 | } |
| 1189 | |
| 1190 | func (m *serverHelloDoneMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloDoneMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/serverHelloDoneMsg#unmarshal().(data []byte) bool { |
| 1191 | return len(data) == 4 |
| 1192 | } |
| 1193 | |
| 1194 | type clientKeyExchangeMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg# struct { |
| 1195 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#raw. []byte |
| 1196 | ciphertextscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#ciphertext. []byte |
| 1197 | } |
| 1198 | |
| 1199 | func (m *clientKeyExchangeMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#equal().(i interface{}) bool { |
| 1200 | m1, ok := i.(*clientKeyExchangeMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#) |
| 1201 | if !ok { |
| 1202 | return false |
| 1203 | } |
| 1204 | |
| 1205 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#raw.) && |
| 1206 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.ciphertextscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#ciphertext., m1.ciphertextscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#ciphertext.) |
| 1207 | } |
| 1208 | |
| 1209 | func (m *clientKeyExchangeMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#marshal().() []byte { |
| 1210 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#raw. != nil { |
| 1211 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#raw. |
| 1212 | } |
| 1213 | length := len(m.ciphertextscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#ciphertext.) |
| 1214 | x := make([]byte, length+4) |
| 1215 | x[0] = typeClientKeyExchangescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeClientKeyExchange. |
| 1216 | x[1] = uint8(length >> 16) |
| 1217 | x[2] = uint8(length >> 8) |
| 1218 | x[3] = uint8(length) |
| 1219 | copy(x[4:], m.ciphertextscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#ciphertext.) |
| 1220 | |
| 1221 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#raw. = x |
| 1222 | return x |
| 1223 | } |
| 1224 | |
| 1225 | func (m *clientKeyExchangeMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#unmarshal().(data []byte) bool { |
| 1226 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#raw. = data |
| 1227 | if len(data) < 4 { |
| 1228 | return false |
| 1229 | } |
| 1230 | l := int(data[1])<<16 | int(data[2])<<8 | int(data[3]) |
| 1231 | if l != len(data)-4 { |
| 1232 | return false |
| 1233 | } |
| 1234 | m.ciphertextscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/clientKeyExchangeMsg#ciphertext. = data[4:] |
| 1235 | return true |
| 1236 | } |
| 1237 | |
| 1238 | type finishedMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg# struct { |
| 1239 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#raw. []byte |
| 1240 | verifyDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#verifyData. []byte |
| 1241 | } |
| 1242 | |
| 1243 | func (m *finishedMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#equal().(i interface{}) bool { |
| 1244 | m1, ok := i.(*finishedMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#) |
| 1245 | if !ok { |
| 1246 | return false |
| 1247 | } |
| 1248 | |
| 1249 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#raw.) && |
| 1250 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.verifyDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#verifyData., m1.verifyDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#verifyData.) |
| 1251 | } |
| 1252 | |
| 1253 | func (m *finishedMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#marshal().() (x []byte) { |
| 1254 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#raw. != nil { |
| 1255 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#raw. |
| 1256 | } |
| 1257 | |
| 1258 | x = make([]byte, 4+len(m.verifyDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#verifyData.)) |
| 1259 | x[0] = typeFinishedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeFinished. |
| 1260 | x[3] = byte(len(m.verifyDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#verifyData.)) |
| 1261 | copy(x[4:], m.verifyDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#verifyData.) |
| 1262 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#raw. = x |
| 1263 | return |
| 1264 | } |
| 1265 | |
| 1266 | func (m *finishedMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#unmarshal().(data []byte) bool { |
| 1267 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#raw. = data |
| 1268 | if len(data) < 4 { |
| 1269 | return false |
| 1270 | } |
| 1271 | m.verifyDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/finishedMsg#verifyData. = data[4:] |
| 1272 | return true |
| 1273 | } |
| 1274 | |
| 1275 | type nextProtoMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg# struct { |
| 1276 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#raw. []byte |
| 1277 | protoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#proto. string |
| 1278 | } |
| 1279 | |
| 1280 | func (m *nextProtoMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#equal().(i interface{}) bool { |
| 1281 | m1, ok := i.(*nextProtoMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#) |
| 1282 | if !ok { |
| 1283 | return false |
| 1284 | } |
| 1285 | |
| 1286 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#raw.) && |
| 1287 | m.protoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#proto. == m1.protoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#proto. |
| 1288 | } |
| 1289 | |
| 1290 | func (m *nextProtoMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#marshal().() []byte { |
| 1291 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#raw. != nil { |
| 1292 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#raw. |
| 1293 | } |
| 1294 | l := len(m.protoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#proto.) |
| 1295 | if l > 255 { |
| 1296 | l = 255 |
| 1297 | } |
| 1298 | |
| 1299 | padding := 32 - (l+2)%32 |
| 1300 | length := l + padding + 2 |
| 1301 | x := make([]byte, length+4) |
| 1302 | x[0] = typeNextProtocolscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeNextProtocol. |
| 1303 | x[1] = uint8(length >> 16) |
| 1304 | x[2] = uint8(length >> 8) |
| 1305 | x[3] = uint8(length) |
| 1306 | |
| 1307 | y := x[4:] |
| 1308 | y[0] = byte(l) |
| 1309 | copy(y[1:], []byte(m.protoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#proto.[0:l])) |
| 1310 | y = y[1+l:] |
| 1311 | y[0] = byte(padding) |
| 1312 | |
| 1313 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#raw. = x |
| 1314 | |
| 1315 | return x |
| 1316 | } |
| 1317 | |
| 1318 | func (m *nextProtoMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#unmarshal().(data []byte) bool { |
| 1319 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#raw. = data |
| 1320 | |
| 1321 | if len(data) < 5 { |
| 1322 | return false |
| 1323 | } |
| 1324 | data = data[4:] |
| 1325 | protoLen := int(data[0]) |
| 1326 | data = data[1:] |
| 1327 | if len(data) < protoLen { |
| 1328 | return false |
| 1329 | } |
| 1330 | m.protoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/nextProtoMsg#proto. = string(data[0:protoLen]) |
| 1331 | data = data[protoLen:] |
| 1332 | |
| 1333 | if len(data) < 1 { |
| 1334 | return false |
| 1335 | } |
| 1336 | paddingLen := int(data[0]) |
| 1337 | data = data[1:] |
| 1338 | if len(data) != paddingLen { |
| 1339 | return false |
| 1340 | } |
| 1341 | |
| 1342 | return true |
| 1343 | } |
| 1344 | |
| 1345 | type certificateRequestMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg# struct { |
| 1346 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#raw. []byte |
| 1347 | // hasSignatureAndHash indicates whether this message includes a list |
| 1348 | // of signature and hash functions. This change was introduced with TLS |
| 1349 | // 1.2. |
| 1350 | hasSignatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#hasSignatureAndHash. bool |
| 1351 | |
| 1352 | certificateTypesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateTypes. []byte |
| 1353 | signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#signatureAndHashes. []SigAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash# |
| 1354 | certificateAuthoritiesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateAuthorities. [][]byte |
| 1355 | } |
| 1356 | |
| 1357 | func (m *certificateRequestMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#equal().(i interface{}) bool { |
| 1358 | m1, ok := i.(*certificateRequestMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#) |
| 1359 | if !ok { |
| 1360 | return false |
| 1361 | } |
| 1362 | |
| 1363 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#raw.) && |
| 1364 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.certificateTypesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateTypes., m1.certificateTypesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateTypes.) && |
| 1365 | eqByteSlicesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqByteSlices().(m.certificateAuthoritiesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateAuthorities., m1.certificateAuthoritiesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateAuthorities.) && |
| 1366 | eqSignatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqSignatureAndHashes().(m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#signatureAndHashes., m1.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#signatureAndHashes.) |
| 1367 | } |
| 1368 | |
| 1369 | func (m *certificateRequestMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#marshal().() (x []byte) { |
| 1370 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#raw. != nil { |
| 1371 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#raw. |
| 1372 | } |
| 1373 | |
| 1374 | // See http://tools.ietf.org/html/rfc4346#section-7.4.4 |
| 1375 | length := 1 + len(m.certificateTypesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateTypes.) + 2 |
| 1376 | casLength := 0 |
| 1377 | for _, ca := range m.certificateAuthoritiesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateAuthorities. { |
| 1378 | casLength += 2 + len(ca) |
| 1379 | } |
| 1380 | length += casLength |
| 1381 | |
| 1382 | if m.hasSignatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#hasSignatureAndHash. { |
| 1383 | length += 2 + 2*len(m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#signatureAndHashes.) |
| 1384 | } |
| 1385 | |
| 1386 | x = make([]byte, 4+length) |
| 1387 | x[0] = typeCertificateRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeCertificateRequest. |
| 1388 | x[1] = uint8(length >> 16) |
| 1389 | x[2] = uint8(length >> 8) |
| 1390 | x[3] = uint8(length) |
| 1391 | |
| 1392 | x[4] = uint8(len(m.certificateTypesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateTypes.)) |
| 1393 | |
| 1394 | copy(x[5:], m.certificateTypesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateTypes.) |
| 1395 | y := x[5+len(m.certificateTypesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateTypes.):] |
| 1396 | |
| 1397 | if m.hasSignatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#hasSignatureAndHash. { |
| 1398 | n := len(m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#signatureAndHashes.) * 2 |
| 1399 | y[0] = uint8(n >> 8) |
| 1400 | y[1] = uint8(n) |
| 1401 | y = y[2:] |
| 1402 | for _, sigAndHash := range m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#signatureAndHashes. { |
| 1403 | y[0] = sigAndHash.Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Hash. |
| 1404 | y[1] = sigAndHash.Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Signature. |
| 1405 | y = y[2:] |
| 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | y[0] = uint8(casLength >> 8) |
| 1410 | y[1] = uint8(casLength) |
| 1411 | y = y[2:] |
| 1412 | for _, ca := range m.certificateAuthoritiesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateAuthorities. { |
| 1413 | y[0] = uint8(len(ca) >> 8) |
| 1414 | y[1] = uint8(len(ca)) |
| 1415 | y = y[2:] |
| 1416 | copy(y, ca) |
| 1417 | y = y[len(ca):] |
| 1418 | } |
| 1419 | |
| 1420 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#raw. = x |
| 1421 | return |
| 1422 | } |
| 1423 | |
| 1424 | func (m *certificateRequestMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#unmarshal().(data []byte) bool { |
| 1425 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#raw. = data |
| 1426 | |
| 1427 | if len(data) < 5 { |
| 1428 | return false |
| 1429 | } |
| 1430 | |
| 1431 | length := uint32(data[1])<<16 | uint32(data[2])<<8 | uint32(data[3]) |
| 1432 | if uint32(len(data))-4 != length { |
| 1433 | return false |
| 1434 | } |
| 1435 | |
| 1436 | numCertTypes := int(data[4]) |
| 1437 | data = data[5:] |
| 1438 | if numCertTypes == 0 || len(data) <= numCertTypes { |
| 1439 | return false |
| 1440 | } |
| 1441 | |
| 1442 | m.certificateTypesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateTypes. = make([]byte, numCertTypes) |
| 1443 | if copy(m.certificateTypesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateTypes., data) != numCertTypes { |
| 1444 | return false |
| 1445 | } |
| 1446 | |
| 1447 | data = data[numCertTypes:] |
| 1448 | |
| 1449 | if m.hasSignatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#hasSignatureAndHash. { |
| 1450 | if len(data) < 2 { |
| 1451 | return false |
| 1452 | } |
| 1453 | sigAndHashLen := uint16(data[0])<<8 | uint16(data[1]) |
| 1454 | data = data[2:] |
| 1455 | if sigAndHashLen&1 != 0 { |
| 1456 | return false |
| 1457 | } |
| 1458 | if len(data) < int(sigAndHashLen) { |
| 1459 | return false |
| 1460 | } |
| 1461 | numSigAndHash := sigAndHashLen / 2 |
| 1462 | m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#signatureAndHashes. = make([]SigAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#, numSigAndHash) |
| 1463 | for i := range m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#signatureAndHashes. { |
| 1464 | m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#signatureAndHashes.[i].Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Hash. = data[0] |
| 1465 | m.signatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#signatureAndHashes.[i].Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Signature. = data[1] |
| 1466 | data = data[2:] |
| 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | if len(data) < 2 { |
| 1471 | return false |
| 1472 | } |
| 1473 | casLength := uint16(data[0])<<8 | uint16(data[1]) |
| 1474 | data = data[2:] |
| 1475 | if len(data) < int(casLength) { |
| 1476 | return false |
| 1477 | } |
| 1478 | cas := make([]byte, casLength) |
| 1479 | copy(cas, data) |
| 1480 | data = data[casLength:] |
| 1481 | |
| 1482 | m.certificateAuthoritiesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateAuthorities. = nil |
| 1483 | for len(cas) > 0 { |
| 1484 | if len(cas) < 2 { |
| 1485 | return false |
| 1486 | } |
| 1487 | caLen := uint16(cas[0])<<8 | uint16(cas[1]) |
| 1488 | cas = cas[2:] |
| 1489 | |
| 1490 | if len(cas) < int(caLen) { |
| 1491 | return false |
| 1492 | } |
| 1493 | |
| 1494 | m.certificateAuthoritiesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateAuthorities. = append(m.certificateAuthoritiesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateRequestMsg#certificateAuthorities., cas[:caLen]) |
| 1495 | cas = cas[caLen:] |
| 1496 | } |
| 1497 | if len(data) > 0 { |
| 1498 | return false |
| 1499 | } |
| 1500 | |
| 1501 | return true |
| 1502 | } |
| 1503 | |
| 1504 | type certificateVerifyMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg# struct { |
| 1505 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#raw. []byte |
| 1506 | hasSignatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#hasSignatureAndHash. bool |
| 1507 | signatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signatureAndHash. SigAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash# |
| 1508 | signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signature. []byte |
| 1509 | } |
| 1510 | |
| 1511 | func (m *certificateVerifyMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#equal().(i interface{}) bool { |
| 1512 | m1, ok := i.(*certificateVerifyMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#) |
| 1513 | if !ok { |
| 1514 | return false |
| 1515 | } |
| 1516 | |
| 1517 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#raw.) && |
| 1518 | m.hasSignatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#hasSignatureAndHash. == m1.hasSignatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#hasSignatureAndHash. && |
| 1519 | m.signatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signatureAndHash..Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Hash. == m1.signatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signatureAndHash..Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Hash. && |
| 1520 | m.signatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signatureAndHash..Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Signature. == m1.signatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signatureAndHash..Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Signature. && |
| 1521 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signature., m1.signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signature.) |
| 1522 | } |
| 1523 | |
| 1524 | func (m *certificateVerifyMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#marshal().() (x []byte) { |
| 1525 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#raw. != nil { |
| 1526 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#raw. |
| 1527 | } |
| 1528 | |
| 1529 | // See http://tools.ietf.org/html/rfc4346#section-7.4.8 |
| 1530 | siglength := len(m.signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signature.) |
| 1531 | length := 2 + siglength |
| 1532 | if m.hasSignatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#hasSignatureAndHash. { |
| 1533 | length += 2 |
| 1534 | } |
| 1535 | x = make([]byte, 4+length) |
| 1536 | x[0] = typeCertificateVerifyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeCertificateVerify. |
| 1537 | x[1] = uint8(length >> 16) |
| 1538 | x[2] = uint8(length >> 8) |
| 1539 | x[3] = uint8(length) |
| 1540 | y := x[4:] |
| 1541 | if m.hasSignatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#hasSignatureAndHash. { |
| 1542 | y[0] = m.signatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signatureAndHash..Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Hash. |
| 1543 | y[1] = m.signatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signatureAndHash..Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Signature. |
| 1544 | y = y[2:] |
| 1545 | } |
| 1546 | y[0] = uint8(siglength >> 8) |
| 1547 | y[1] = uint8(siglength) |
| 1548 | copy(y[2:], m.signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signature.) |
| 1549 | |
| 1550 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#raw. = x |
| 1551 | |
| 1552 | return |
| 1553 | } |
| 1554 | |
| 1555 | func (m *certificateVerifyMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#unmarshal().(data []byte) bool { |
| 1556 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#raw. = data |
| 1557 | |
| 1558 | if len(data) < 6 { |
| 1559 | return false |
| 1560 | } |
| 1561 | |
| 1562 | length := uint32(data[1])<<16 | uint32(data[2])<<8 | uint32(data[3]) |
| 1563 | if uint32(len(data))-4 != length { |
| 1564 | return false |
| 1565 | } |
| 1566 | |
| 1567 | data = data[4:] |
| 1568 | if m.hasSignatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#hasSignatureAndHash. { |
| 1569 | m.signatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signatureAndHash..Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Hash. = data[0] |
| 1570 | m.signatureAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signatureAndHash..Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Signature. = data[1] |
| 1571 | data = data[2:] |
| 1572 | } |
| 1573 | |
| 1574 | if len(data) < 2 { |
| 1575 | return false |
| 1576 | } |
| 1577 | siglength := int(data[0])<<8 + int(data[1]) |
| 1578 | data = data[2:] |
| 1579 | if len(data) != siglength { |
| 1580 | return false |
| 1581 | } |
| 1582 | |
| 1583 | m.signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/certificateVerifyMsg#signature. = data |
| 1584 | |
| 1585 | return true |
| 1586 | } |
| 1587 | |
| 1588 | type newSessionTicketMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg# struct { |
| 1589 | rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#raw. []byte |
| 1590 | ticketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#ticket. []byte |
| 1591 | lifetimeHintscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#lifetimeHint. uint32 |
| 1592 | } |
| 1593 | |
| 1594 | func (m *newSessionTicketMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#) equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#equal().(i interface{}) bool { |
| 1595 | m1, ok := i.(*newSessionTicketMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#) |
| 1596 | if !ok { |
| 1597 | return false |
| 1598 | } |
| 1599 | |
| 1600 | return bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#raw., m1.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#raw.) && |
| 1601 | bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(m.ticketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#ticket., m1.ticketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#ticket.) |
| 1602 | } |
| 1603 | |
| 1604 | func (m *newSessionTicketMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#marshal().() (x []byte) { |
| 1605 | if m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#raw. != nil { |
| 1606 | return m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#raw. |
| 1607 | } |
| 1608 | |
| 1609 | // See http://tools.ietf.org/html/rfc5077#section-3.3 |
| 1610 | ticketLen := len(m.ticketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#ticket.) |
| 1611 | length := 2 + 4 + ticketLen |
| 1612 | x = make([]byte, 4+length) |
| 1613 | x[0] = typeNewSessionTicketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeNewSessionTicket. |
| 1614 | x[1] = uint8(length >> 16) |
| 1615 | x[2] = uint8(length >> 8) |
| 1616 | x[3] = uint8(length) |
| 1617 | x[8] = uint8(ticketLen >> 8) |
| 1618 | x[9] = uint8(ticketLen) |
| 1619 | copy(x[10:], m.ticketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#ticket.) |
| 1620 | |
| 1621 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#raw. = x |
| 1622 | |
| 1623 | return |
| 1624 | } |
| 1625 | |
| 1626 | func (m *newSessionTicketMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#unmarshal().(data []byte) bool { |
| 1627 | m.rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#raw. = data |
| 1628 | |
| 1629 | if len(data) < 10 { |
| 1630 | return false |
| 1631 | } |
| 1632 | |
| 1633 | length := uint32(data[1])<<16 | uint32(data[2])<<8 | uint32(data[3]) |
| 1634 | if uint32(len(data))-4 != length { |
| 1635 | return false |
| 1636 | } |
| 1637 | |
| 1638 | ticketLen := int(data[8])<<8 + int(data[9]) |
| 1639 | if len(data)-10 != ticketLen { |
| 1640 | return false |
| 1641 | } |
| 1642 | |
| 1643 | m.lifetimeHintscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#lifetimeHint. = uint32(data[4])<<24 | uint32(data[5])<<16 | uint32(data[6])<<8 | uint32(data[7]) |
| 1644 | m.ticketscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/newSessionTicketMsg#ticket. = data[10:] |
| 1645 | |
| 1646 | return true |
| 1647 | } |
| 1648 | |
| 1649 | type helloRequestMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/helloRequestMsg# struct { |
| 1650 | } |
| 1651 | |
| 1652 | func (*helloRequestMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/helloRequestMsg#) marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/helloRequestMsg#marshal().() []byte { |
| 1653 | return []byte{typeHelloRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/typeHelloRequest., 0, 0, 0} |
| 1654 | } |
| 1655 | |
| 1656 | func (*helloRequestMsgscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/helloRequestMsg#) unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/helloRequestMsg#unmarshal().(data []byte) bool { |
| 1657 | return len(data) == 4 |
| 1658 | } |
| 1659 | |
| 1660 | func eqUint16sscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqUint16s().(x, y []uint16) bool { |
| 1661 | if len(x) != len(y) { |
| 1662 | return false |
| 1663 | } |
| 1664 | for i, v := range x { |
| 1665 | if y[i] != v { |
| 1666 | return false |
| 1667 | } |
| 1668 | } |
| 1669 | return true |
| 1670 | } |
| 1671 | |
| 1672 | func eqCurveIDsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqCurveIDs().(x, y []CurveIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/CurveID#) bool { |
| 1673 | if len(x) != len(y) { |
| 1674 | return false |
| 1675 | } |
| 1676 | for i, v := range x { |
| 1677 | if y[i] != v { |
| 1678 | return false |
| 1679 | } |
| 1680 | } |
| 1681 | return true |
| 1682 | } |
| 1683 | |
| 1684 | func eqStringsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqStrings().(x, y []string) bool { |
| 1685 | if len(x) != len(y) { |
| 1686 | return false |
| 1687 | } |
| 1688 | for i, v := range x { |
| 1689 | if y[i] != v { |
| 1690 | return false |
| 1691 | } |
| 1692 | } |
| 1693 | return true |
| 1694 | } |
| 1695 | |
| 1696 | func eqByteSlicesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqByteSlices().(x, y [][]byte) bool { |
| 1697 | if len(x) != len(y) { |
| 1698 | return false |
| 1699 | } |
| 1700 | for i, v := range x { |
| 1701 | if !bytesscip-go gomod github.com/golang/go/src go1.16 bytes/.Equalscip-go gomod github.com/golang/go/src go1.16 bytes/Equal().(v, y[i]) { |
| 1702 | return false |
| 1703 | } |
| 1704 | } |
| 1705 | return true |
| 1706 | } |
| 1707 | |
| 1708 | func eqSignatureAndHashesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/eqSignatureAndHashes().(x, y []SigAndHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#) bool { |
| 1709 | if len(x) != len(y) { |
| 1710 | return false |
| 1711 | } |
| 1712 | for i, v := range x { |
| 1713 | v2 := y[i] |
| 1714 | if v.Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Hash. != v2.Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Hash. || v.Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Signature. != v2.Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/tls`/SigAndHash#Signature. { |
| 1715 | return false |
| 1716 | } |
| 1717 | } |
| 1718 | return true |
| 1719 | } |