配置SPN实现AD帐号委托(活动目录)

If you cannot see the Delegation tab, do one or both of the
following: Register a Service Principal Name (SPN) for the user
account with the Setspn utility in the support tools on your CD.
Delegation is only intended to be used by service accounts, which
should have registered SPNs, as opposed to a regular user account
which typically does not have SPNs.

 

setspn -A HTTP/servername domain\svcaccount­

­

setspn -L domain\svcaccont­

转载于:https://www.cnblogs.com/loofeer/archive/2009/10/27/1590351.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的SPN加密算法的C++实现,使用PPT例子4.1中的参数设置: ```c++ #include <iostream> #include <string> #include <bitset> #include <vector> using namespace std; const int BLOCK_SIZE = 16; // 分组长度 const int KEY_SIZE = 64; // 密钥长度 const int ROUNDS = 4; // 轮数 const unsigned char S_BOX[4][4] = { {0x9, 0x4, 0xa, 0xb}, {0xd, 0x1, 0x8, 0x5}, {0x6, 0x2, 0x0, 0x3}, {0xc, 0xe, 0xf, 0x7} }; // S盒 const unsigned char P_BOX[BLOCK_SIZE] = {0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}; // P盒 // 密钥扩展 vector<unsigned long long> expand_key(unsigned long long key) { vector<unsigned long long> key_schedule; for (int i = 0; i < ROUNDS; i++) { unsigned long long round_key = key >> (KEY_SIZE - BLOCK_SIZE); key_schedule.push_back(round_key); key = ((key << BLOCK_SIZE) & ((1ull << KEY_SIZE) - 1)) | round_key; } return key_schedule; } // S盒层 vector<vector<unsigned char>> s_layer(vector<vector<unsigned char>> state) { vector<vector<unsigned char>> new_state; for (auto row : state) { vector<unsigned char> new_row; for (auto x : row) { new_row.push_back(S_BOX[x >> 4][x & 0xf]); } new_state.push_back(new_row); } return new_state; } // P盒层 vector<vector<unsigned char>> p_layer(vector<vector<unsigned char>> state) { vector<vector<unsigned char>> new_state; for (auto row : state) { vector<unsigned char> new_row; for (int i = 0; i < BLOCK_SIZE; i++) { new_row.push_back(row[P_BOX[i]]); } new_state.push_back(new_row); } return new_state; } // 轮函数 vector<vector<unsigned char>> round_function(vector<vector<unsigned char>> state, unsigned long long round_key) { for (auto& row : state) { for (auto& x : row) { x ^= (round_key >> ((BLOCK_SIZE - 1 - (&x - &row[0])) * 4)) & 0xf; } } state = s_layer(state); state = p_layer(state); return state; } // SPN加密 string encrypt(string plaintext, unsigned long long key) { vector<unsigned long long> key_schedule = expand_key(key); vector<vector<unsigned char>> state; for (int i = 0; i < plaintext.size(); i += BLOCK_SIZE / 8) { state.push_back(vector<unsigned char>(plaintext.begin() + i, plaintext.begin() + i + BLOCK_SIZE / 8)); } for (int i = 0; i < ROUNDS; i++) { state = round_function(state, key_schedule[i]); } string ciphertext; for (auto row : state) { for (auto x : row) { ciphertext += bitset<8>(x).to_string(); } } return ciphertext; } // 测试 int main() { string plaintext = "Hello, world!"; unsigned long long key = 0x0123456789abcdef; string ciphertext = encrypt(plaintext, key); cout << "Plaintext: " << plaintext << endl; cout << "Ciphertext: " << ciphertext << endl; return 0; } ``` 在以上代码中,我们使用了vector和bitset等STL库来处理数据,首先定义了SPN算法的参数,包括分组长度、密钥长度、轮数、S盒和P盒。然后我们实现了密钥扩展、S盒层、P盒层和轮函数等基本操作。最后定义了SPN加密函数,将明文转换为二进制数据,然后进行轮函数迭代,得到密文并返回。在测试部分,我们使用一个简单的字符串作为明文,然后对其进行加密,并输出明文和密文。 需要注意的是,在C++中,我们使用了unsigned long long类型来表示64位的二进制数据,同时还需要使用bitset<8>类型来将每个字节转换为8位二进制字符串。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值