void setSecurityLevel ( final int securityLevel ) throws InvalidArgumentException { logger . trace ( format ( "setSecurityLevel to %d" , securityLevel ) ) ; if ( securityCurveMapping . isEmpty ( ) ) { throw new InvalidArgumentException ( "Security curve mapping has no entries." ) ; } if ( ! securityCurveMapping . containsKey ( securityLevel ) ) { StringBuilder sb = new StringBuilder ( ) ; String sp = "" ; for ( int x : securityCurveMapping . keySet ( ) ) { sb . append ( sp ) . append ( x ) ; sp = ", " ; } throw new InvalidArgumentException ( format ( "Illegal security level: %d. Valid values are: %s" , securityLevel , sb . toString ( ) ) ) ; } String lcurveName = securityCurveMapping . get ( securityLevel ) ; logger . debug ( format ( "Mapped curve strength %d to %s" , securityLevel , lcurveName ) ) ; X9ECParameters params = ECNamedCurveTable . getByName ( lcurveName ) ; //Check if can match curve name to requested strength. if ( params == null ) { InvalidArgumentException invalidArgumentException = new InvalidArgumentException ( format ( "Curve %s defined for security strength %d was not found." , curveName , securityLevel ) ) ; logger . error ( invalidArgumentException ) ; throw invalidArgumentException ; } curveName = lcurveName ; this . securityLevel = securityLevel ; }
Security Level determines the elliptic curve used in key generation