Class CipherSuite
java.lang.Object
org.metricshub.ipmi.core.coding.security.CipherSuite
Provides cipher suite (authentication, confidentiality and integrity
algorithms used during the session).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.unused since 2.0.00; this constant will be removed in 3.0. -
Constructor Summary
ConstructorsConstructorDescriptionCipherSuite(byte id, byte authenticationAlgorithm, byte confidentialityAlgorithm, byte integrityAlgorithm) Creates a cipher suite. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns a new instance of this suite, with uninitialized algorithms: opening a session keys the algorithms of its suite, so two sessions must never share an instance.static CipherSuiteforId(int id) Creates one of the standard cipher suites (IPMI 2.0 table 22-20) from its ID, with the algorithms the specification assigns to it: the suite to use with a BMC whose offer is not read.Returns instance of AuthenticationAlgorithm class.bytestatic List<CipherSuite>getCipherSuites(byte[] bytes) Builds Cipher Suites collection from raw data received byGetChannelCipherSuitescommands.Returns instance of ConfidentialityAlgorithm class.bytestatic CipherSuitegetEmpty()bytegetId()Returns instance of IntegrityAlgorithm class.bytevoidinitializeAlgorithms(byte[] sik) Initializes algorithms contained in thisCipherSuite.voidinitializeAlgorithms(byte[] sik, byte[] password) Initializes algorithms contained in thisCipherSuite: the HMAC integrity algorithms and the confidentiality algorithm are keyed with the Session Integrity Key, MD5-128 integrity (suites 11 to 14) with the user's password (IPMI 2.0 section 13.28.4).booleanTells whether this library implements the algorithms of this suite.static StringlistIds(List<CipherSuite> suites) Lists the IDs of the given suites, for messages.static MacnewMacInstance(String algorithmName) Constructs a Mac object that implements the given MAC algorithm.voidwipeKeys()Wipes the key of the integrity algorithm of the suite, if it was keyed (the password for MD5-128 integrity), once the session is over.
-
Field Details
-
NOT_YET_IMPLEMENTED_MESSAGE
Deprecated.unused since 2.0.00; this constant will be removed in 3.0.A message no exception carries: the exceptions about the algorithms this library does not implement name the algorithm, such asConfidentiality algorithm XRC4-40 is not implemented.- See Also:
-
-
Constructor Details
-
CipherSuite
public CipherSuite(byte id, byte authenticationAlgorithm, byte confidentialityAlgorithm, byte integrityAlgorithm) Creates a cipher suite.- Parameters:
id- the ID of the cipher suiteauthenticationAlgorithm- the code of the authentication algorithm (SecurityConstants)confidentialityAlgorithm- the code of the confidentiality algorithmintegrityAlgorithm- the code of the integrity algorithm
-
-
Method Details
-
getId
public byte getId()- Returns:
- the ID of the cipher suite (IPMI 2.0 table 22-20)
-
getAuthenticationAlgorithmCode
public byte getAuthenticationAlgorithmCode()- Returns:
- the code of the authentication algorithm (IPMI 2.0 table 13-17:
SecurityConstants.AA_*), whether the library implements it or not
-
getIntegrityAlgorithmCode
public byte getIntegrityAlgorithmCode()- Returns:
- the code of the integrity algorithm (IPMI 2.0 table 13-18:
SecurityConstants.IA_*), whether the library implements it or not
-
getConfidentialityAlgorithmCode
public byte getConfidentialityAlgorithmCode()- Returns:
- the code of the confidentiality algorithm (IPMI 2.0 table 13-19:
SecurityConstants.CA_*), whether the library implements it or not
-
copy
Returns a new instance of this suite, with uninitialized algorithms: opening a session keys the algorithms of its suite, so two sessions must never share an instance.- Returns:
- a cipher suite with the same ID and algorithms
-
initializeAlgorithms
public void initializeAlgorithms(byte[] sik) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException Initializes algorithms contained in thisCipherSuite. A suite with MD5-128 integrity (11 to 14) is keyed with the password, which this method does not have: useinitializeAlgorithms(byte[], byte[])for it.- Parameters:
sik- - Session Integrity Key calculated during the opening of the session or user password if 'one-key' logins are enabled.- Throws:
IllegalArgumentException- - when an algorithm of the suite is not implemented, or when the suite uses MD5-128 integrityInvalidKeyException- - when initiation of the algorithm failsNoSuchAlgorithmException- - when initiation of the algorithm failsNoSuchPaddingException- - when initiation of the algorithm fails
-
initializeAlgorithms
public void initializeAlgorithms(byte[] sik, byte[] password) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException Initializes algorithms contained in thisCipherSuite: the HMAC integrity algorithms and the confidentiality algorithm are keyed with the Session Integrity Key, MD5-128 integrity (suites 11 to 14) with the user's password (IPMI 2.0 section 13.28.4).- Parameters:
sik- the Session Integrity Key calculated during the opening of the sessionpassword- the password of the user, as sent to the BMC; null for an empty password- Throws:
IllegalArgumentException- - when an algorithm of the suite is not implementedInvalidKeyException- - when initiation of the algorithm failsNoSuchAlgorithmException- - when initiation of the algorithm failsNoSuchPaddingException- - when initiation of the algorithm fails
-
getAuthenticationAlgorithm
Returns instance of AuthenticationAlgorithm class.- Returns:
- the authentication algorithm of the suite
- Throws:
IllegalArgumentException- when authentication algorithm code is incorrect.
-
getIntegrityAlgorithm
Returns instance of IntegrityAlgorithm class.- Returns:
- the integrity algorithm of the suite
- Throws:
IllegalArgumentException- when integrity algorithm code is incorrect.
-
getConfidentialityAlgorithm
Returns instance of ConfidentialityAlgorithm class.- Returns:
- the confidentiality algorithm of the suite
- Throws:
IllegalArgumentException- when confidentiality algorithm code is incorrect.
-
getCipherSuites
Builds Cipher Suites collection from raw data received byGetChannelCipherSuitescommands. Cannot be executed inGetChannelCipherSuitesResponseDatasince data comes in 16-byte packets and is fragmented.A standard record (IPMI 2.0 table 22-19) is C0h, the suite ID, then the algorithm tags. The algorithms of the standard suites 0 to 19 are those of IPMI 2.0 table 22-20, whatever the tags say, as in ipmitool and FreeIPMI: the records come unauthenticated, and a suite 17 whose tags were stripped must not become a suite without integrity. OEM records (C1h, the OEM suite ID, a 3-byte IANA, then the tags), whose suite IDs are vendor-specific, records with a reserved suite ID, and malformed or truncated records are skipped.
- Parameters:
bytes- - concatenated Cipher Suite Records received byGetChannelCipherSuitescommands.- Returns:
- list of the standard Cipher Suites offered by BMC, in the BMC's order (including suites whose
algorithms this library does not implement, see
isSupported())
-
isSupported
public boolean isSupported()Tells whether this library implements the algorithms of this suite. The suites listed bygetCipherSuites(byte[])include the ones it does not implement (xRC4 confidentiality: suites 4, 5, 9, 10, 13, 14, 18 and 19), which fail when the session is opened.- Returns:
- true when the authentication, integrity and confidentiality algorithms are all implemented
-
getEmpty
- Returns:
CipherSuitewith algorithms set toAuthenticationRakpNone,ConfidentialityNoneandIntegrityNone.
-
forId
Creates one of the standard cipher suites (IPMI 2.0 table 22-20) from its ID, with the algorithms the specification assigns to it: the suite to use with a BMC whose offer is not read.- Parameters:
id- the ID of the suite, 0 to 19- Returns:
- the suite, with uninitialized algorithms
- Throws:
IllegalArgumentException- when the ID is not a standard suite
-
listIds
Lists the IDs of the given suites, for messages.- Parameters:
suites- the suites, or null- Returns:
- the comma-separated IDs, or "none" when there is no suite
-
wipeKeys
public void wipeKeys()Wipes the key of the integrity algorithm of the suite, if it was keyed (the password for MD5-128 integrity), once the session is over. -
newMacInstance
Constructs a Mac object that implements the given MAC algorithm.- Parameters:
algorithmName- the name of the algorithm to use- Returns:
- The Mac object that implements the specified MAC algorithm.
-