// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.cms;

import org.bouncycastle.asn1.cms.SignerInfo;
import java.io.IOException;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;

public class CMSPatchKit
{
    public static SignerInformation createNonDERSignerInfo(final SignerInformation signerInformation) {
        return new DLSignerInformation(signerInformation);
    }
    
    public static SignerInformation createWithSignatureAlgorithm(final SignerInformation signerInformation, final AlgorithmIdentifier algorithmIdentifier) {
        return new ModEncAlgSignerInformation(signerInformation, algorithmIdentifier);
    }
    
    private static class DLSignerInformation extends SignerInformation
    {
        protected DLSignerInformation(final SignerInformation signerInformation) {
            super(signerInformation);
        }
        
        @Override
        public byte[] getEncodedSignedAttributes() throws IOException {
            return this.signedAttributeSet.getEncoded("DL");
        }
    }
    
    private static class ModEncAlgSignerInformation extends SignerInformation
    {
        protected ModEncAlgSignerInformation(final SignerInformation signerInformation, final AlgorithmIdentifier algorithmIdentifier) {
            super(signerInformation, editEncAlg(signerInformation.info, algorithmIdentifier));
        }
        
        private static SignerInfo editEncAlg(final SignerInfo signerInfo, final AlgorithmIdentifier algorithmIdentifier) {
            return new SignerInfo(signerInfo.getSID(), signerInfo.getDigestAlgorithm(), signerInfo.getAuthenticatedAttributes(), algorithmIdentifier, signerInfo.getEncryptedDigest(), signerInfo.getUnauthenticatedAttributes());
        }
    }
}
