public int deserialize()

in src/main/java/com/amazonaws/encryptionsdk/model/CiphertextHeaders.java [536:605]


  public int deserialize(final byte[] b, final int off, int maxEncryptedDataKeys)
      throws ParseException {
    if (b == null) {
      return 0;
    }

    maxEncryptedDataKeys_ = maxEncryptedDataKeys;

    int parsedBytes = 0;
    try {
      parsedBytes += parseVersion(b, off + parsedBytes);

      final ParsingStep[] steps;
      switch (version_) {
        case 1: // Initial version
          steps =
              new ParsingStep[] {
                this::configV1,
                this::parseType,
                this::parseAlgoId,
                this::parseMessageId,
                this::parseEncryptionContextLen,
                this::parseEncryptionContext,
                this::parseEncryptedDataKeyCount,
                this::parseEncryptedKeyBlobList,
                this::parseContentType,
                this::parseReservedField,
                this::parseNonceLen,
                this::parseFramePayloadLength,
                this::parseHeaderNonce,
                this::parseHeaderTag,
                this::parseComplete
              };
          break;
        case 2:
          steps =
              new ParsingStep[] {
                this::parseAlgoId,
                this::configV2, // Must come after we've parsed the algorithm
                this::parseMessageId,
                this::parseEncryptionContextLen,
                this::parseEncryptionContext,
                this::parseEncryptedDataKeyCount,
                this::parseEncryptedKeyBlobList,
                this::parseContentType,
                this::parseFramePayloadLength,
                this::parseSuiteData,
                this::parseHeaderTag,
                this::parseComplete
              };
          break;
        default:
          throw new BadCiphertextException("Invalid version");
      }

      for (final ParsingStep step : steps) {
        parsedBytes += step.parse(b, off + parsedBytes);
      }

    } catch (final PartialParseException e) {
      // this results when we do partial parsing and there aren't enough
      // bytes to parse; ignore it and return the bytes parsed thus far.
      parsedBytes += e.bytesParsed_;
    } catch (final ParseException e) {
      // this results when we do partial parsing and there aren't enough
      // bytes to parse; ignore it and return the bytes parsed thus far.
    }

    return parsedBytes;
  }