Calculates the ciphertext message footer length, given a complete header.

    :param header: Complete message header object
    :type header: aws_encryption_sdk.structures.MessageHeader
    :rtype: int
189126
def footer_length(header):
    
    footer_length = 0
    if header.algorithm.signing_algorithm_info is not None:
        footer_length += 2  # Signature Length
        footer_length += header.algorithm.signature_len  # Signature
    return footer_length
447614
public void checkSize(int length, boolean huffman) throws HpackException.SessionException {
        // Apply a huffman fudge factor
        if (huffman)
            length = (length * 4) / 3;
        if ((_size + length) > _maxSize)
            throw new HpackException.SessionException("Header too large %d > %d", _size + length, _maxSize);
    }
153196
private void parseTrailerHeaders() throws IOException {
        try {
            this.footers = AbstractMessageParser.parseHeaders(in,
                    constraints.getMaxHeaderCount(),
                    constraints.getMaxLineLength(),
                    null);
        } catch (final HttpException ex) {
            final IOException ioe = new MalformedChunkCodingException("Invalid footer: "
                    + ex.getMessage());
            ioe.initCause(ex);
            throw ioe;
        }
    }
1278712
private void processHeader() {
    int type = nextFrame.readUnsignedByte();
    if ((type & RESERVED_MASK) != 0) {
      throw Status.INTERNAL.withDescription(
          "gRPC frame header malformed: reserved bits not zero")
          .asRuntimeException();
    }
    compressedFlag = (type & COMPRESSED_FLAG_MASK) != 0;

    // Update the required length to include the length of the frame.
    requiredLength = nextFrame.readInt();
    if (requiredLength < 0 || requiredLength > maxInboundMessageSize) {
      throw Status.RESOURCE_EXHAUSTED.withDescription(
          String.format("gRPC message exceeds maximum size %d: %d",
              maxInboundMessageSize, requiredLength))
          .asRuntimeException();
    }

    currentMessageSeqNo++;
    statsTraceCtx.inboundMessage(currentMessageSeqNo);
    transportTracer.reportMessageReceived();
    // Continue reading the frame body.
    state = State.BODY;
  }
557629
def read_header(self):
        
        with fopen(self.vpk_path, 'rb') as f:
            (self.signature,
             self.version,
             self.tree_length
             ) = struct.unpack("3I", f.read(3*4))

            # original format - headerless
            if self.signature != 0x55aa1234:
                raise ValueError("File is not VPK (invalid magic)")
            # v1
            elif self.version == 1:
                self.header_length += 4*3
            # v2 with extended header
            #
            # according to http://forum.xentax.com/viewtopic.php?f=10&t=11208
            # struct VPKDirHeader_t
            # {
            #    int32 m_nHeaderMarker;
            #    int32 m_nVersion;
            #    int32 m_nDirectorySize;
            #    int32 m_nEmbeddedChunkSize;
            #    int32 m_nChunkHashesSize;
            #    int32 m_nSelfHashesSize;
            #    int32 m_nSignatureSize;
            # }
            elif self.version == 2:
                (self.embed_chunk_length,
                 self.chunk_hashes_length,
                 self.self_hashes_length,
                 self.signature_length
                 ) = struct.unpack("4I", f.read(4*4))
                self.header_length += 4*7

                f.seek(self.tree_length + self.embed_chunk_length + self.chunk_hashes_length, 1)

                assert self.self_hashes_length == 48, "Self hashes section size mismatch"

                (self.tree_checksum,
                 self.chunk_hashes_checksum,
                 self.file_checksum,
                 ) = struct.unpack("16s16s16s", f.read(16*3))
            else:
                raise ValueError("Invalid header, or unsupported version")
443160
function HeaderRW(countrw, keyrw, valrw, options) {
    this.countrw = countrw;
    this.keyrw = keyrw;
    this.valrw = valrw;
    this.maxHeaderCount = options.maxHeaderCount;
    this.maxKeyLength = options.maxKeyLength;
    bufrw.Base.call(this);
}
3740
def _encode_message_header(cls, client_id, correlation_id, request_key,
                               api_version=0):
        
        return (struct.pack('>hhih',
                            request_key,          # ApiKey
                            api_version,          # ApiVersion
                            correlation_id,       # CorrelationId
                            len(client_id)) +     # ClientId size
                client_id)
334325
def _process_content_header(self, channel, payload):
        
        partial = self.partial_messages[channel]
        partial.add_header(payload)

        if partial.complete:
            #
            # a bodyless message, we're done
            #
            self.queue.put((channel, partial.method_sig, partial.args, partial.msg))
            del self.partial_messages[channel]
            self.expected_types[channel] = 1
        else:
            #
            # wait for the content-body
            #
            self.expected_types[channel] = 3
1373923
def parse_results_header(cls, header):
        
        header = IORMetricsExtractor.RE_MULTIPLE_SPACES.sub(' ', header)
        header = header.split(' ')
        return header
1197345
private static void setContentLength(HttpRequest req, HttpHeaders headers, int contentLength) {
        // https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4
        // prohibits to send message body for below cases.
        // and in those cases, content should be empty.
        if (req.method() == HttpMethod.HEAD || ArmeriaHttpUtil.isContentAlwaysEmpty(headers.status())) {
            return;
        }
        headers.setInt(HttpHeaderNames.CONTENT_LENGTH, contentLength);
    }
448120
public static int getContentLengthValue(H2HeaderField header) {
        if ("content-length".equalsIgnoreCase(header.getName())) {
            return Integer.parseInt(header.getValue());
        }
        return -1;
    }
590559
def _read_header(self):
        ''''''

        try:
            # Read the entire header
            header = self._fp.read(96)
            if len(header) != 96:
                raise InvalidScryptFileFormat("Incomplete header")

            # Magic number
            if header[0:6] != b'scrypt':
                raise InvalidScryptFileFormat('Invalid magic number").')

            # Version (we only support 0)
            version = get_byte(header[6])
            if version != 0:
                raise InvalidScryptFileFormat('Unsupported version (%d)' % version)

            # Scrypt parameters
            self._N = 1 << get_byte(header[7])
            (self._r, self._p) = struct.unpack('>II', header[8:16])
            self._salt = header[16:48]

            # Generate the key
            self._key = hash(self._password, self._salt, self._N, self._r, self._p, 64)

            # Header Checksum
            checksum = header[48:64]
            calculate_checksum = hashlib.sha256(header[0:48]).digest()[:16]
            if checksum != calculate_checksum:
                raise InvalidScryptFileFormat('Incorrect header checksum')

            # Stream checksum
            checksum = header[64:96]
            self._checksumer = hmac.new(self.key[32:], msg = header[0:64], digestmod = hashlib.sha256)
            if checksum != self._checksumer.digest():
                raise InvalidScryptFileFormat('Incorrect header stream checksum')
            self._checksumer.update(header[64:96])

            # Prepare the AES engine
            self._crypto = aesctr.AESCounterModeOfOperation(key = self.key[:32])

            self._done_header = True

        except InvalidScryptFileFormat as e:
            self.close()
            raise e

        except Exception as e:
            self.close()
            raise InvalidScryptFileFormat('Header error (%s)' % e)
1248988
def getCiphertextLen(self, ciphertext):
        

        plaintext_length = self.getPlaintextLen(ciphertext)
        ciphertext_length = plaintext_length + Encrypter._CTXT_EXPANSION
        return ciphertext_length
906880
def _build_message_headers(self):
        
        basic_deliver = self._inbound.pop(0)
        if not isinstance(basic_deliver, specification.Basic.Deliver):
            LOGGER.warning(
                'Received an out-of-order frame: %s was '
                'expecting a Basic.Deliver frame',
                type(basic_deliver)
            )
            return None
        content_header = self._inbound.pop(0)
        if not isinstance(content_header, ContentHeader):
            LOGGER.warning(
                'Received an out-of-order frame: %s was '
                'expecting a ContentHeader frame',
                type(content_header)
            )
            return None

        return basic_deliver, content_header
1327379
protected TokenCodes findHeaderLength(WsByteBuffer buff) throws MalformedMessageException {

        TokenCodes rc = TokenCodes.TOKEN_RC_MOREDATA;

        if (null == buff) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "findHeaderLength: null buffer provided");
            }
            return rc;
        }

        byte b;
        int numSpaces = 0;
        // start with any pre-existing data
        int length = this.parsedTokenLength;
        while (true) {
            if (this.bytePosition >= this.byteLimit) {
                if (!fillByteCache(buff)) {
                    // no more data
                    break;
                }
            }
            b = this.byteCache[this.bytePosition++];

            // look for the colon marking the end
            if (BNFHeaders.COLON == b) {
                length -= numSpaces; // remove any "trailing" white space

                if (numSpaces > 0) {
                    //PI13987
                    //found trailing whitespace
                    this.foundTrailingWhitespace = true;
                }

                rc = TokenCodes.TOKEN_RC_DELIM;
                break;
            }

            // if we hit whitespace, then keep track of the number of spaces so
            // that we can easily trim that off at the end. This will end up
            // ignoring whitespace that is inside the header name if that does
            // happen

            if (BNFHeaders.SPACE == b || BNFHeaders.TAB == b) {
                numSpaces++;
            } else {
                // reset the counter on any non-space or colon
                numSpaces = 0;
            }

            // check for possible CRLF
            if (BNFHeaders.CR == b || BNFHeaders.LF == b) {
                // Note: would be nice to print the failing data but would need
                // to keep track of where we started inside here, then what about
                // data straddling bytecaches, etc?
                throw new MalformedMessageException("Invalid CRLF found in header name");
            }

            length++;
            // check the limit on a token size
            if (length > this.limitTokenSize) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "findTokenLength: length is too big: " + length);
                }
                throw new MalformedMessageException("Token length: " + length);
            }
        } // end of the while

        this.parsedTokenLength = length;
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "findHeaderLength: " + rc.getName() + "; len=" + length);
        }
        return rc;
    }
812213
def header(self):
        

        if self._header_encoding is None:
            return self._header
        else:
            return self._header.decode(self._header_encoding)
291770
def _parse_header(cls, header_proto, resource):
        
        header = header_proto()
        try:
            header_bytes = base64.b64decode(resource['header'])
            header.ParseFromString(header_bytes)
        except (KeyError, TypeError, ValueError, DecodeError):
            header = resource.get('header', None)
            LOGGER.error(
                'The validator sent a resource with %s %s',
                'a missing header' if header is None else 'an invalid header:',
                header or '')
            raise errors.ResourceHeaderInvalid()

        resource['header'] = cls._message_to_dict(header)
        return resource