1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 package com.ohos.hapsigntool.hap.sign; 17 18 import com.ohos.hapsigntool.hap.config.SignerConfig; 19 import com.ohos.hapsigntool.hap.exception.SignatureException; 20 21 /** 22 * interface of PKCS#7 signed data generator 23 * 24 * @since 2021/12/21 25 */ 26 @FunctionalInterface 27 public interface Pkcs7Generator { 28 Pkcs7Generator BC = new BcPkcs7Generator(); 29 30 /** 31 * Generate PKCS#7 signed data with the specific content and signer config. 32 * 33 * @param content PKCS7 data, content of unsigned file digest. 34 * @param signerConfig configurations of signer. 35 * @return PKCS7 signed data. 36 * @throws SignatureException if an error occurs when generating PKCS#7 block. 37 */ generateSignedData(byte[] content, SignerConfig signerConfig)38 byte[] generateSignedData(byte[] content, SignerConfig signerConfig) throws SignatureException; 39 } 40