KeymasterBlobArgument.java revision 534bf9c2683e4e4a37d4348cb7d0945b2116fd53
1/** 2 * Copyright (c) 2015, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.security.keymaster; 18 19import android.os.Parcel; 20import android.os.Parcelable; 21 22/** 23 * @hide 24 */ 25class KeymasterBlobArgument extends KeymasterArgument { 26 public final byte[] blob; 27 28 public KeymasterBlobArgument(int tag, byte[] blob) { 29 super(tag); 30 switch (KeymasterDefs.getTagType(tag)) { 31 case KeymasterDefs.KM_BIGNUM: 32 case KeymasterDefs.KM_BYTES: 33 break; // OK. 34 default: 35 throw new IllegalArgumentException("Bad blob tag " + tag); 36 } 37 this.blob = blob; 38 } 39 40 public KeymasterBlobArgument(int tag, Parcel in) { 41 super(tag); 42 blob = in.createByteArray(); 43 } 44 45 @Override 46 public void writeValue(Parcel out) { 47 out.writeByteArray(blob); 48 } 49} 50