2019-04-25 20:12:30 +02:00
/*
2020-01-24 11:10:40 +01:00
* Copyright ( c ) 2018 - 2020 Atmosphère - NX
2019-04-25 20:12:30 +02:00
*
* This program is free software ; you can redistribute it and / or modify it
* under the terms and conditions of the GNU General Public License ,
* version 2 , as published by the Free Software Foundation .
*
* This program is distributed in the hope it will be useful , but WITHOUT
* ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License for
* more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# pragma once
# include <stratosphere.hpp>
2019-10-24 11:30:10 +02:00
namespace ams : : spl {
2019-04-25 20:12:30 +02:00
2019-10-16 21:50:04 +02:00
class DeprecatedService : public sf : : IServiceObject {
2019-06-21 10:36:00 +02:00
protected :
enum class CommandId {
/* 1.0.0+ */
2019-07-01 12:53:46 +02:00
GetConfig = 0 ,
ExpMod = 1 ,
GenerateAesKek = 2 ,
LoadAesKey = 3 ,
GenerateAesKey = 4 ,
SetConfig = 5 ,
GenerateRandomBytes = 7 ,
ImportLotusKey = 9 ,
DecryptLotusMessage = 10 ,
IsDevelopment = 11 ,
GenerateSpecificAesKey = 12 ,
DecryptRsaPrivateKeyDeprecated = 13 ,
DecryptRsaPrivateKey = 13 ,
DecryptAesKey = 14 ,
CryptAesCtrDeprecated = 15 ,
CryptAesCtr = 15 ,
ComputeCmac = 16 ,
ImportEsKey = 17 ,
2019-10-16 21:50:04 +02:00
UnwrapTitleKeyDeprecated = 18 ,
2019-07-01 12:53:46 +02:00
UnwrapTitleKey = 18 ,
LoadTitleKey = 19 ,
2019-06-21 10:36:00 +02:00
/* 2.0.0+ */
2019-10-16 21:50:04 +02:00
UnwrapCommonTitleKeyDeprecated = 20 ,
2019-07-01 12:53:46 +02:00
UnwrapCommonTitleKey = 20 ,
AllocateAesKeyslot = 21 ,
FreeAesKeyslot = 22 ,
GetAesKeyslotAvailableEvent = 23 ,
2019-06-21 10:36:00 +02:00
/* 3.0.0+ */
2019-07-01 12:53:46 +02:00
SetBootReason = 24 ,
GetBootReason = 25 ,
2019-06-21 10:36:00 +02:00
} ;
public :
DeprecatedService ( ) { /* ... */ }
virtual ~ DeprecatedService ( ) { /* ... */ }
protected :
/* Actual commands. */
2019-10-16 21:50:04 +02:00
virtual Result GetConfig ( sf : : Out < u64 > out , u32 which ) ;
virtual Result ExpMod ( const sf : : OutPointerBuffer & out , const sf : : InPointerBuffer & base , const sf : : InPointerBuffer & exp , const sf : : InPointerBuffer & mod ) ;
virtual Result GenerateAesKek ( sf : : Out < AccessKey > out_access_key , KeySource key_source , u32 generation , u32 option ) ;
2020-05-12 00:04:51 +02:00
virtual Result LoadAesKey ( s32 keyslot , AccessKey access_key , KeySource key_source ) ;
2019-10-16 21:50:04 +02:00
virtual Result GenerateAesKey ( sf : : Out < AesKey > out_key , AccessKey access_key , KeySource key_source ) ;
2019-06-21 10:36:00 +02:00
virtual Result SetConfig ( u32 which , u64 value ) ;
2019-10-16 21:50:04 +02:00
virtual Result GenerateRandomBytes ( const sf : : OutPointerBuffer & out ) ;
virtual Result ImportLotusKey ( const sf : : InPointerBuffer & src , AccessKey access_key , KeySource key_source , u32 option ) ;
virtual Result DecryptLotusMessage ( sf : : Out < u32 > out_size , const sf : : OutPointerBuffer & out , const sf : : InPointerBuffer & base , const sf : : InPointerBuffer & mod , const sf : : InPointerBuffer & label_digest ) ;
virtual Result IsDevelopment ( sf : : Out < bool > is_dev ) ;
virtual Result GenerateSpecificAesKey ( sf : : Out < AesKey > out_key , KeySource key_source , u32 generation , u32 which ) ;
virtual Result DecryptRsaPrivateKey ( const sf : : OutPointerBuffer & dst , const sf : : InPointerBuffer & src , AccessKey access_key , KeySource key_source , u32 option ) ;
virtual Result DecryptAesKey ( sf : : Out < AesKey > out_key , KeySource key_source , u32 generation , u32 option ) ;
2020-05-12 00:04:51 +02:00
virtual Result CryptAesCtrDeprecated ( const sf : : OutBuffer & out_buf , s32 keyslot , const sf : : InBuffer & in_buf , IvCtr iv_ctr ) ;
virtual Result CryptAesCtr ( const sf : : OutNonSecureBuffer & out_buf , s32 keyslot , const sf : : InNonSecureBuffer & in_buf , IvCtr iv_ctr ) ;
virtual Result ComputeCmac ( sf : : Out < Cmac > out_cmac , s32 keyslot , const sf : : InPointerBuffer & in_buf ) ;
2019-10-16 21:50:04 +02:00
virtual Result ImportEsKey ( const sf : : InPointerBuffer & src , AccessKey access_key , KeySource key_source , u32 option ) ;
virtual Result UnwrapTitleKeyDeprecated ( sf : : Out < AccessKey > out_access_key , const sf : : InPointerBuffer & base , const sf : : InPointerBuffer & mod , const sf : : InPointerBuffer & label_digest ) ;
virtual Result UnwrapTitleKey ( sf : : Out < AccessKey > out_access_key , const sf : : InPointerBuffer & base , const sf : : InPointerBuffer & mod , const sf : : InPointerBuffer & label_digest , u32 generation ) ;
2020-05-12 00:04:51 +02:00
virtual Result LoadTitleKey ( s32 keyslot , AccessKey access_key ) ;
2019-10-16 21:50:04 +02:00
virtual Result UnwrapCommonTitleKeyDeprecated ( sf : : Out < AccessKey > out_access_key , KeySource key_source ) ;
virtual Result UnwrapCommonTitleKey ( sf : : Out < AccessKey > out_access_key , KeySource key_source , u32 generation ) ;
2020-05-12 00:04:51 +02:00
virtual Result AllocateAesKeyslot ( sf : : Out < s32 > out_keyslot ) ;
virtual Result FreeAesKeyslot ( s32 keyslot ) ;
2019-10-16 21:50:04 +02:00
virtual void GetAesKeyslotAvailableEvent ( sf : : OutCopyHandle out_hnd ) ;
2019-06-21 10:36:00 +02:00
virtual Result SetBootReason ( BootReasonValue boot_reason ) ;
2019-10-16 21:50:04 +02:00
virtual Result GetBootReason ( sf : : Out < BootReasonValue > out ) ;
2019-06-21 10:36:00 +02:00
public :
DEFINE_SERVICE_DISPATCH_TABLE {
2019-10-16 21:50:04 +02:00
MAKE_SERVICE_COMMAND_META ( GetConfig ) ,
MAKE_SERVICE_COMMAND_META ( ExpMod ) ,
MAKE_SERVICE_COMMAND_META ( GenerateAesKek ) ,
MAKE_SERVICE_COMMAND_META ( LoadAesKey ) ,
MAKE_SERVICE_COMMAND_META ( GenerateAesKey ) ,
MAKE_SERVICE_COMMAND_META ( SetConfig ) ,
MAKE_SERVICE_COMMAND_META ( GenerateRandomBytes ) ,
MAKE_SERVICE_COMMAND_META ( ImportLotusKey ) ,
MAKE_SERVICE_COMMAND_META ( DecryptLotusMessage ) ,
MAKE_SERVICE_COMMAND_META ( IsDevelopment ) ,
MAKE_SERVICE_COMMAND_META ( GenerateSpecificAesKey ) ,
MAKE_SERVICE_COMMAND_META ( DecryptRsaPrivateKey ) ,
MAKE_SERVICE_COMMAND_META ( DecryptAesKey ) ,
2020-04-14 07:19:44 +02:00
MAKE_SERVICE_COMMAND_META ( CryptAesCtrDeprecated , hos : : Version_1_0_0 , hos : : Version_1_0_0 ) ,
MAKE_SERVICE_COMMAND_META ( CryptAesCtr , hos : : Version_2_0_0 ) ,
2019-10-16 21:50:04 +02:00
MAKE_SERVICE_COMMAND_META ( ComputeCmac ) ,
MAKE_SERVICE_COMMAND_META ( ImportEsKey ) ,
2020-04-14 07:19:44 +02:00
MAKE_SERVICE_COMMAND_META ( UnwrapTitleKeyDeprecated , hos : : Version_1_0_0 , hos : : Version_2_0_0 ) ,
MAKE_SERVICE_COMMAND_META ( UnwrapTitleKey , hos : : Version_3_0_0 ) ,
2019-10-16 21:50:04 +02:00
MAKE_SERVICE_COMMAND_META ( LoadTitleKey ) ,
2020-06-12 12:27:29 +02:00
MAKE_SERVICE_COMMAND_META ( UnwrapCommonTitleKeyDeprecated , hos : : Version_2_0_0 , hos : : Version_2_3_0 ) ,
2020-04-14 07:19:44 +02:00
MAKE_SERVICE_COMMAND_META ( UnwrapCommonTitleKey , hos : : Version_3_0_0 ) ,
2019-10-16 21:50:04 +02:00
2020-05-12 00:04:51 +02:00
MAKE_SERVICE_COMMAND_META ( AllocateAesKeyslot /* Atmosphere extension: This was added in hos::Version_2_0_0, but is allowed on older firmware by atmosphere. */ ) ,
MAKE_SERVICE_COMMAND_META ( FreeAesKeyslot /* Atmosphere extension: This was added in hos::Version_2_0_0, but is allowed on older firmware by atmosphere. */ ) ,
MAKE_SERVICE_COMMAND_META ( GetAesKeyslotAvailableEvent /* Atmosphere extension: This was added in hos::Version_2_0_0, but is allowed on older firmware by atmosphere. */ ) ,
2019-10-16 21:50:04 +02:00
2020-04-14 07:19:44 +02:00
MAKE_SERVICE_COMMAND_META ( SetBootReason , hos : : Version_3_0_0 ) ,
MAKE_SERVICE_COMMAND_META ( GetBootReason , hos : : Version_3_0_0 ) ,
2019-06-21 10:36:00 +02:00
} ;
} ;
}