@Test public void anonymousSignatureTest() throws CryptoException { SignatureAndHashAlgorithm algorithm = SignatureAndHashAlgorithm.ANONYMOUS_SHA1; byte[] signature = SignatureCalculator.generateSignature(algorithm, context.getChooser(), new byte[0]); assertArrayEquals(signature, new byte[0]); }
public static byte[] generateSignature(SignatureAndHashAlgorithm algorithm, Chooser chooser, byte[] toBeSigned) throws CryptoException { switch (algorithm.getSignatureAlgorithm()) { case ANONYMOUS: return generateAnonymousSignature(chooser, toBeSigned, algorithm); case DSA: return generateDSASignature(chooser, toBeSigned, algorithm); case ECDSA: return generateECDSASignature(chooser, toBeSigned, algorithm); case RSA: case RSA_PSS_PSS: case RSA_PSS_RSAE: return generateRSASignature(chooser, toBeSigned, algorithm); case GOSTR34102001: return generateGost01Signature(chooser, toBeSigned, algorithm); case GOSTR34102012_256: case GOSTR34102012_512: return generateGost12Signature(chooser, toBeSigned, algorithm); default: throw new UnsupportedOperationException("Unknown SignatureAlgorithm:" + algorithm.getSignatureAlgorithm().name()); } }
SignatureCalculator { public static byte[] generateSignature(SignatureAndHashAlgorithm algorithm, Chooser chooser, byte[] toBeSigned) throws CryptoException { switch (algorithm.getSignatureAlgorithm()) { case ANONYMOUS: return generateAnonymousSignature(chooser, toBeSigned, algorithm); case DSA: return generateDSASignature(chooser, toBeSigned, algorithm); case ECDSA: return generateECDSASignature(chooser, toBeSigned, algorithm); case RSA: case RSA_PSS_PSS: case RSA_PSS_RSAE: return generateRSASignature(chooser, toBeSigned, algorithm); case GOSTR34102001: return generateGost01Signature(chooser, toBeSigned, algorithm); case GOSTR34102012_256: case GOSTR34102012_512: return generateGost12Signature(chooser, toBeSigned, algorithm); default: throw new UnsupportedOperationException("Unknown SignatureAlgorithm:" + algorithm.getSignatureAlgorithm().name()); } } }
SignatureCalculator { public static byte[] generateSignature(SignatureAndHashAlgorithm algorithm, Chooser chooser, byte[] toBeSigned) throws CryptoException { switch (algorithm.getSignatureAlgorithm()) { case ANONYMOUS: return generateAnonymousSignature(chooser, toBeSigned, algorithm); case DSA: return generateDSASignature(chooser, toBeSigned, algorithm); case ECDSA: return generateECDSASignature(chooser, toBeSigned, algorithm); case RSA: case RSA_PSS_PSS: case RSA_PSS_RSAE: return generateRSASignature(chooser, toBeSigned, algorithm); case GOSTR34102001: return generateGost01Signature(chooser, toBeSigned, algorithm); case GOSTR34102012_256: case GOSTR34102012_512: return generateGost12Signature(chooser, toBeSigned, algorithm); default: throw new UnsupportedOperationException("Unknown SignatureAlgorithm:" + algorithm.getSignatureAlgorithm().name()); } } private  SignatureCalculator(); }
SignatureCalculator { public static byte[] generateSignature(SignatureAndHashAlgorithm algorithm, Chooser chooser, byte[] toBeSigned) throws CryptoException { switch (algorithm.getSignatureAlgorithm()) { case ANONYMOUS: return generateAnonymousSignature(chooser, toBeSigned, algorithm); case DSA: return generateDSASignature(chooser, toBeSigned, algorithm); case ECDSA: return generateECDSASignature(chooser, toBeSigned, algorithm); case RSA: case RSA_PSS_PSS: case RSA_PSS_RSAE: return generateRSASignature(chooser, toBeSigned, algorithm); case GOSTR34102001: return generateGost01Signature(chooser, toBeSigned, algorithm); case GOSTR34102012_256: case GOSTR34102012_512: return generateGost12Signature(chooser, toBeSigned, algorithm); default: throw new UnsupportedOperationException("Unknown SignatureAlgorithm:" + algorithm.getSignatureAlgorithm().name()); } } private  SignatureCalculator(); static byte[] generateSignature(SignatureAndHashAlgorithm algorithm, Chooser chooser, byte[] toBeSigned); static byte[] generateSignature(PrivateKey key, byte[] toBeSigned, SignatureAndHashAlgorithm algorithm,
            BadRandom random, Chooser chooser); static byte[] generateRSASignature(Chooser chooser, byte[] toBeSigned, SignatureAndHashAlgorithm algorithm); static byte[] generateDSASignature(Chooser chooser, byte[] toBeSigned, SignatureAndHashAlgorithm algorithm); static byte[] generateECDSASignature(Chooser chooser, byte[] toBeSigned, SignatureAndHashAlgorithm algorithm); static byte[] generateAnonymousSignature(Chooser chooser, byte[] toBeSigned,
            SignatureAndHashAlgorithm algorithm); }
SignatureCalculator { public static byte[] generateSignature(SignatureAndHashAlgorithm algorithm, Chooser chooser, byte[] toBeSigned) throws CryptoException { switch (algorithm.getSignatureAlgorithm()) { case ANONYMOUS: return generateAnonymousSignature(chooser, toBeSigned, algorithm); case DSA: return generateDSASignature(chooser, toBeSigned, algorithm); case ECDSA: return generateECDSASignature(chooser, toBeSigned, algorithm); case RSA: case RSA_PSS_PSS: case RSA_PSS_RSAE: return generateRSASignature(chooser, toBeSigned, algorithm); case GOSTR34102001: return generateGost01Signature(chooser, toBeSigned, algorithm); case GOSTR34102012_256: case GOSTR34102012_512: return generateGost12Signature(chooser, toBeSigned, algorithm); default: throw new UnsupportedOperationException("Unknown SignatureAlgorithm:" + algorithm.getSignatureAlgorithm().name()); } } private  SignatureCalculator(); static byte[] generateSignature(SignatureAndHashAlgorithm algorithm, Chooser chooser, byte[] toBeSigned); static byte[] generateSignature(PrivateKey key, byte[] toBeSigned, SignatureAndHashAlgorithm algorithm,
            BadRandom random, Chooser chooser); static byte[] generateRSASignature(Chooser chooser, byte[] toBeSigned, SignatureAndHashAlgorithm algorithm); static byte[] generateDSASignature(Chooser chooser, byte[] toBeSigned, SignatureAndHashAlgorithm algorithm); static byte[] generateECDSASignature(Chooser chooser, byte[] toBeSigned, SignatureAndHashAlgorithm algorithm); static byte[] generateAnonymousSignature(Chooser chooser, byte[] toBeSigned,
            SignatureAndHashAlgorithm algorithm);  }