如何在用非对称加密算法实现身份认证?以及如何用对称加密算法实现加密数据传输?[高分!]

antpower 2003-11-10 07:41:06

这个过程以及实现需要的算法!
...全文
1011 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
antpower 2003-11-12
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2451/2451860.xml?temp=.4824793
antpower 2003-11-11
  • 打赏
  • 举报
回复
sunxuandong(孙某人):

我需要:
非对称加密算法 RSA
对称加密算法 DES
最好是能告诉我使用方法。fish51flying@yahoo.com.cn
antpower 2003-11-11
  • 打赏
  • 举报
回复
多谢!
这是一个比较系统的协议。

密码算法的这个过程我也知道一些。
关键是具体实施的时候,如何处理。关于实施的我的几个问题如下。

1. 一般我们在向系统注册的时候,一定会注册一个用户名和用户密码的,
这个用户名和用户密码和我们产生的public_key,private_key 有什么关系,即
public_key和private_key是如何产生的,并且这个两个密钥如何保存。
2. 如何使用RSA算法产生public_key,private_key.
3. 我面对的问题不是1:1通讯问题,而是多个用户和服务器通信的问题。
那么这个sym_key对不同的用户肯定是不同的,该如何管理,是不是也用一个
hash表保存?
可能还有问题!


yintongshun 2003-11-11
  • 打赏
  • 举报
回复
贴不开,算了,给你地址:
http://developer.ccidnet.com/pub/disp/Article?columnID=1138&articleID=24750&pageNO=1
yintongshun 2003-11-11
  • 打赏
  • 举报
回复
Web Service的安全 (2)
作者:宁凯编译 发文时间:2002.09.10 16:34:53

Web Services和安全 API 机制


因特网上常用的传统安全技术对Web Service来说是远远不够的。主要问题在它们的传输存在依赖性。例如,最广泛使用的安全技术SSL (Secure Socket Layer)受限于网络通信端点。更准确的说,身份特性只能指定给常被多个Web Service共享的通信端点。

其他的安全技术,也就是说GSS-API (Generic Security Service Application Programmers Interface) 和基于GSS-API的安全机制(诸如SPKM (Simple Public Key Mechanism) 和Kerberos), 主要是为松散连接的体系结构而设计的。GSS-API 独立于传输和安全机制(安全机制独立性意味着密码技术、身份表示和数据签名等潜在的技术被完全封装了)。当今Web Service中最常用的安全机制仍然是SSL,但是SPKM和 Kerberos的使用也在不断增长。SPKM 是基于上面介绍的非对称密码技术原理的。所以它非常适合Web Service的分散环境。; Kerberos使用对称密码技术。如果您关心安全问题,支持这些高级安全选项的Web Services 产品和技术就是您所关心问题的最好答案。


运行中的安全:鉴别、授权和数据保密


鉴别、授权和数据保密是安全体系结构的三个主要基础。我们来看一看解释这些概念的一个简单示例吧。首先我们将看一看银行帐户功能的简单实现。请检查AccountImpl Java class的代码。

/*
* AccountImpl.java
*
* Created on December 13, 2001, 9:25 AM
*/
package com.systinet.demos.bank;
// imports of WASP security
import org.idoox.security.AuthResult;
import org.idoox.security.Credentials;
import org.idoox.security.PrincipalAuthenticator;
import org.idoox.security.server.Current;
import org.idoox.webservice.server.Initializable;
import org.idoox.webservice.server.WebServiceContext;
/**
* Account implementation
*/
public class AccountImpl
implements Account, Initializable
{
private double balance = 0;
private String number = "";

public AccountImpl()
{
this.number = ""+System.currentTimeMillis();
}

public void init(WebServiceContext context)
{
authenticate();
}

public void destroy()
{
// do nothing here
}

/**
* Deposits to the account
* @param amount amount of many to deposit
* @throws AuthenticationException if authentication fails
*/
synchronized public void deposit(double amount)
throws AuthenticationException
{
checkAuth();
this.balance += amount;
}

/**
* Withdraw from the account
* @param amount amount to withdraw
* @throws UnsufficientFundsException thrown if account doesn't hava enough funds
* @throws AuthenticationException if authentication fails
*/
synchronized public void withdraw(double amount)
throws UnsufficientFundsException, AuthenticationException
{
checkAuth();
if(amount < this.balance) {
this.balance = this.balance - amount;
}
else {
throw new UnsufficientFundsException("The withdrawal of " + amount +
" was requested but the balance is
only " +
this.balance+" .");
}
}

/**
* Returns the account balance
* @return the actual balance of the account
* @throws AuthenticationException if authentication fails
*/
synchronized public double getBalance()
throws AuthenticationException
{
checkAuth();
return this.balance;
}

/**
* Sets the account balance
* @param amount the actual balance of the account
* @throws AuthenticationException if authentication fails
*/
synchronized public void setBalance(double amount)
throws AuthenticationException
{
checkAuth();
this.balance = amount;
}

/**
* Returns the account number
* @return account number
* @throws AuthenticationException if authentication fails
*/
public String getAccountNumber()
throws AuthenticationException
{
checkAuth();
return this.number;
}

/**
* Sets the account number
* @param accountNumber account number
* @throws AuthenticationException if authentication fails
*/
public void setAccountNumber(String accountNumber)
throws AuthenticationException
{
checkAuth();
this.number = accountNumber;
}

/**
* Close the account
* @throws AuthenticationException if authentication fails
*/
public void close()
throws AuthenticationException
{
checkAuth();
org.idoox.webservice.server.WebServiceContext context =
org.idoox.webservice.server.WebServiceContext.getInstance();
org.idoox.webservice.server.LifeCycleService lc =
context.getLifeCycleService();
lc.disposeServiceInstance(this);
}

/**
* Creates and sets the security identity credentials if they are
* not alread set
*/
private synchronized void authenticate()
{
Current current = Current.getInstance();
if (current.getCredentials() == null) {
PrincipalAuthenticator auth = current.getAuthenticator();
AuthResult result = auth.authenticate("bank-server",
"password".getBytes());
if (result.resultCode != AuthResult.AUTH_STATUS_SUCCESS) {
System.err.println("Unable to authenticate");
}
current.setCredentials(new Credentials[] { result.creds });
}
}

/**
* Performs very simple authorization based on the hardcoded
* identity name, which is able to manipulate the account.
*
* @throws AuthenticationException if the client is not authorized
*/
private void checkAuth()
throws AuthenticationException
{
Current current = Current.getInstance();
Credentials credentials = current.getReceivedCredentials();
if(credentials != null) {
String caller = credentials.getName();
if(caller == null || !caller.equals("john")) {
throw new AuthenticationException("Access denied.");
}
}
}
}
yintongshun 2003-11-11
  • 打赏
  • 举报
回复
Web Service的安全 (1)
作者:宁凯编译 发文时间:2002.09.10 16:34:53

本部分我们将对安全和Web Service予以介绍并加以评论。这个话题是有争议的,因为开发人员是第一次采用Web Service技术,安全问题就成了它们经常提到的话题。首先,我们回顾一些基本的概念,然后再看一看一些公共安全技术,例如SSL(Secure Socket Layer)。然后,我们将分析鉴别和授权所涉及的过程,还有数据保密性。


Web Services 安全简介


首先,我们将简要地介绍一些概念和体系结构,这些概念和体系结构是Web Service 安全的基础。

非对称密码技术——私钥和公钥

第二次世界大战期间,美国海军发现无线传输加密的最好形式之一就是用Najavo Indian语言进行交流。这种语言和其他语言天生就没有关联。这一简单的技术从来没失败过,甚至胜过更复杂的代码书和计算机制。

从那时起,现代密码技术就得到飞速发展。为了便于在此进行讨论,介绍两种基本的密码术算法:对称(常规)和非对称(也就是所熟知的公开-秘密密钥密码技术)。在对称密码技术中,对文件或者报文进行加密的密钥(或者编码)与对文件或者报文进行解密的密钥是完全相同的。而在非对称密码技术中,对文件或者报文进行加密和解密所使用的密钥是不同的。从算术角度看,这两个密钥是相关联的,但是由其中的一个密钥导出另一个密钥却很难实现。一个用户可以将公开密钥分配给其他用户,并对这些用户发送给自己的报文进行加密。这个用户将对私钥严格保密并利用它对使用公钥发送的报文进行解密。

从计算复杂性角度来看,使用对称加密技术传送报文比使用计算复杂性更强的非对称技术效率更高。由于可以自由分配公开密钥,非对称技术在大型团体中更具优势。

身份认证

身份认证是实现Web service集中工作的关键。现在大多数Web Service处于单独工作状态,但是大家都在谈论将Web Service聚集在一起,创建更加强大且更加复杂的业务服务。然而,Web Service 的集中要求服务能够共享信息,这一点在我们开始考虑在服务中添加安全时显得尤为重要。

请考虑大多数Web Service是如何实现安全的?提供安全Web Service的每一种业务都维护有授权用户列表,其中每一位用户使用userid/password(用户ID/口令)来进行身份鉴别。但是这对于复杂的服务来说并没有太多意义。而且这也是我们之所以听到象微软这样的大公司宣布Passport(护照)将使用Kerberos V5.0支持联合鉴别,还有Sun 启动Liberty Alliance (自由联盟工程)的理由。

对等的通信实体进行鉴别期间将使用身份特性。它将辨别、授权和审核等考虑在内。当前最常用的方法就是每一种安全身份特性将具有名称、私钥和X.509证书。X.509 证书包含特定身份特性的公共特征(aka credentials) ,这其中包括公钥。

数据签名

数据签名只能校对数据来源。如果使用私钥对数据加密,那么能够正确解密的任何人都可以很容易的校对数据的来源:正确解密就是说数据是使用相应的私钥加密的。由于私钥总是需要保密,而且只有生成私钥的主人唯一占有它,正确的数据解密当然就证明了它的来源。

不幸的是,非对称算法速度太慢,因此要使用特定的散列函数(例如MD5或者 SHA)。这些特定的散列函数首先将计算数据的手印(例如, MD5是16 字节而SHA是20 字节)加以符号表示。接收方使用相同的函数计算手印,使用公开密钥对采用符号表示的手印进行解密,最后将计算所得的手印和解密所得的手印进行比较。如果两者能够完全匹配,那么数据的来源就得到了证实。

认证证书

我们首先来看看证书是如何创建的。首先,生成密钥对(公钥和私钥)。接下来,创建一个所谓的证书签名请求Certificate Signing Request (CSR)。CSR只不过是一个数据集,其中包含了证书中所包括的全部信息(包括公开密钥) 并且使用所生成的私钥对其进行签名。下一步, CSR将被发送到证明授权机构(Certification Authority)由其根据CSR创建证书并用私钥签署证书。通过签署证书,证明授权机构(Certification Authority)将核实证书包含的有效数据。信任这个证明授权机构的任何人都可以使用它的证书(更准确的公开密钥)并可以核实所签署的证书。将证书存储到一个专门的可信赖的存储之处能够表明我们信任某一身份特性这一事实。证书核实可以扩展到更高的级别。因此,可以使用某一身份特性签署证书,而这一身份特性是由另一身份特性签署的。如果我们信任这一串中的所有证书,这就意味着我们也信任这一串中其它更高级别的证书。
sunxuandong 2003-11-11
  • 打赏
  • 举报
回复
我是搞信息安全的 有各种加密解密源程序
Onega 2003-11-10
  • 打赏
  • 举报
回复
非对称加密算法 RSA (public_key, private_key)
对称加密算法 DES/3DES/AES sym_key

A send public_kay_a To B
B encrypt sym_key with public_kay_a , send the result to A
A decrypt what he received with private_key, get sym_key
A and B communicate with data encypted with sym_key

18,357

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧