1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20package org.apache.harmony.security.x509.tsp; 21 22import org.apache.harmony.security.asn1.ASN1OctetString; 23import org.apache.harmony.security.asn1.ASN1Sequence; 24import org.apache.harmony.security.asn1.ASN1Type; 25import org.apache.harmony.security.asn1.BerInputStream; 26import org.apache.harmony.security.x509.AlgorithmIdentifier; 27 28/** 29 * As defined in Time-Stamp Protocol (TSP) 30 * (http://www.ietf.org/rfc/rfc3161.txt) 31 * 32 * MessageImprint ::= SEQUENCE { 33 * hashAlgorithm AlgorithmIdentifier, 34 * hashedMessage OCTET STRING 35 * } 36 * 37 */ 38public class MessageImprint { 39 private final AlgorithmIdentifier algId; 40 private final byte [] hashedMessage; 41 42 public MessageImprint(AlgorithmIdentifier algId, byte [] hashedMessage){ 43 this.algId = algId; 44 this.hashedMessage = hashedMessage; 45 } 46 47 public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] { 48 AlgorithmIdentifier.ASN1, 49 ASN1OctetString.getInstance()}) { 50 51 protected Object getDecodedObject(BerInputStream in) { 52 Object[] values = (Object[]) in.content; 53 return new MessageImprint( 54 (AlgorithmIdentifier)values[0], 55 (byte[])values[1]); 56 } 57 58 protected void getValues(Object object, Object[] values) { 59 MessageImprint mi = (MessageImprint) object; 60 values[0] = mi.algId; 61 values[1] = mi.hashedMessage; 62 } 63 }; 64} 65 66