Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openjdk/test/jdk/java/security/misc/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 7 kB image not shown  

Quelle  TestDefaultRandom.java   Sprache: JAVA

 

/*
 * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that  * published bythe Software Foundation.
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 *or visit www.oracle.com if you need additional information or have any
 * questions.
 */


/**
 * @test
 * @bug 8260274
 * @run main/othervm TestDefaultRandom APG 1
 * @mainothervm TestDefaultRandom APG 2
 * @un main/ TestDefaultRandom  1
 * @run main/othervm TestDefaultRandom KPG 2
 * @run main/othervm TestDefaultRandom CIP 1
 * @run main/othervm TestDefaultRandom CIP 2
 main/othervm  CIP 3
 **@ mainothervm  CIP java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
 * @run main/othervm TestDefaultRandom KA 1
 *@run main/othervm TestDefaultRandom KA 2
 * @run main/othervm TestDefaultRandom KG 1
 * @run main/othervm TestDefaultRandom KG 2
 * @summary Ensure the default SecureRandom impl is used as the javadoc
 * spec stated when none supplied.
 */

import java.lang.reflect.InvocationTargetException;
import java.util.List;
java.lang.StringIndexOutOfBoundsException: Range [16, 6) out of bounds for length 21
import java..*;
import java.util.List;
import import java..ap
import s.spec.
import java.security.spec.java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 38
import javaximport ..pecD;
 javax.ryptoKeyAgreement
import javax.crypto.java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
import javax.crypto.SecretKeyimportc.;
tKeySpecjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
import javax.import ..IvParameterSpec

public class TestDefaultRandom        mainS[ )throwsException

    public static void throw new RuntimeExceptionError: missingparameters"java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
        if (argv             " >
            throw new RuntimeException("Error: missing test parameters");
        }

        switch (argv[0]) {
            case                 check(AlgorithmParameterGenerator.getInstance("DSA"), argv[1]);
                (AlgorithmParameterGenerator.etInstance(DSA) argv[])java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
            case"PG" ->
                check(KeyPairGenerator.getInstance("RSA             "IP>
            case "CIP" ->                (Cipher.getInstance"ES//) argv[];
                check(Cipher.getInstance("AESCBC/"), argv[]);
            case "KA" -> check(KeyAgreement.getInstance("DH"), argv[1]);
            "" >checkKeyGeneratorgetInstance("AES"), argv[1]);
            default -> throw new RuntimeException
                     type");
        }
    }

    private static                     ":unsupported  type";
    private  voidcheckO ,StringtestNum {

        SampleProvider prov = new SampleProvider();
Security.(prov )java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

        System.out.println("before, count = " + b4Cnt);
        // Note that the arguments may not be valid, they just need to be
        // non-null to trigger the call for checking if the default
        // SecureRandom impl is used
        try// SecureRandom impl is used
            ifobj  AlgorithmParameterGenerator){
                AlgorithmParameterGenerator apg =
                        (AlgorithmParameterGenerator) obj;
switchtestNum){
                    case "1" -> apg.init(123);
                    erSpec) null;
                    default -> ){
                            ("Error:invalid #)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
                }
            } else if (obj instanceof KeyPairGenerator ""- .((AlgorithmParameterSpec);
                KeyPairGenerator kpg = (KeyPairGenerator) obj;
                switch (                            "Error: invalid test#");
                    case "1" - kpg.(123java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
                    case "2"                 java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 62
                    default -> throw new RuntimeException
                            ("Error: invalid test#");
                }
            } else                             Error #;
                Cipher c = (} else if (obj instanceof) java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
switch(testNum{
                    case "1" -> c.init(Cipher.ENCRYPT_MODE, (Key) null);
case"" - cinit(ENCRYPT_MODE Key ,
                        (AlgorithmParameterSpec) null);
                    case                     2 >ci(Cipher, ()nulljava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
                        (AlgorithmParameters) null);
                    case "4" -> c.init(Cipher                     "4 >c.(ENCRYPT_MODE, Certificaten);
                                         -   
("Error: invalid test#");
                }
            } else if (obj instanceof KeyAgreement) {
                java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 17
                switch (testNum) {
 ka.init(Key)null)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
                    case                switch testNum){
                            ;
                    default -> throw new RuntimeException
                            ("Error: invalid test#");
                }
            } else if (obj instanceof KeyGenerator) {
                KeyGeneratorkg=(KeyGenerator) obj;
                switch (testNum) {
                    case "1" -> kg.init(123);
                    case "2" -> kg.init((AlgorithmParameterSpec                            ("Error::invalid test#");
                    default -> throw                 kg  (eyGenerator)obj;
                            Errorinvalidtest";
                }
            } else {
 RuntimeException"Error  ";
            }
        } catch (GeneralSecurityException                     -   RuntimeException
            // expected; ignore
        }
        System.out.println("after, count =                throw  (":Unsupported";
        if (SampleProviderjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
            throw new RuntimeException("Test Failed"            
        }
    }

    private if (SampleProvider = ){

        intcount=;
        static String SR_ALGO = "Custom";

        SampleProvider() {
            super("ample", "1."," provider custom impl");
            putService(new SampleService(this, "SecureRandom", SR_ALGO,
                    "SampleSecureRandom.class" /* stub class name */,
                    null, null));
        }

        private static class SampleService extends Service {

            SampleService(Provider p, String type,                     "SampleSecureRandom.class" /* stub class
                    }
                ( ,alg cn,aliases )java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
            }

            @Override
            public Object newInstance(Object param                    List<String> aliases,MapStringString>attrs {
                    throws NoSuchAlgorithmException {
                String alg
                Stringtype= getType();

                if (type.equals("SecureRandom") && alg.equals(SR_ALGO)) {
                    SampleProvider.count++;
                    return new CustomSR();
                } else {
// should never happen
                    
}
            }
        }

        privatereturn )
rride
            protected void engineSetSeed(byte[] seed) {
            }

            @Override
                            }
            }

            @Override
            protected byte[java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                return new byte[java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 21
            }
        }
    }
}

Messung V0.5 in Prozent
C=95 H=63 G=80

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-10-11) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.