You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by dr...@apache.org on 2015/01/22 22:48:10 UTC
[31/45] directory-kerberos git commit: DIRKRB-149 New layout
structure with the new name "Apache Kerby"
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/pkinit/TrustedCertifiers.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/pkinit/TrustedCertifiers.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/pkinit/TrustedCertifiers.java
deleted file mode 100644
index 1d3c347..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/pkinit/TrustedCertifiers.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.pa.pkinit;
-
-import org.apache.kerberos.kerb.spec.KrbSequenceOfType;
-
-/**
- trustedCertifiers SEQUENCE OF ExternalPrincipalIdentifier OPTIONAL,
- */
-public class TrustedCertifiers extends KrbSequenceOfType<ExternalPrincipalIdentifier> {
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/PaTokenChallenge.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/PaTokenChallenge.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/PaTokenChallenge.java
deleted file mode 100644
index cb0ec8d..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/PaTokenChallenge.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.pa.token;
-
-import org.apache.haox.asn1.type.Asn1FieldInfo;
-import org.apache.kerberos.kerb.spec.KrbSequenceType;
-
-/**
- PA-TOKEN-CHALLENGE ::= SEQUENCE {
- tokenInfos [0] SEQUENCE (SIZE(1..MAX)) OF TokenInfo,
- }
-*/
-public class PaTokenChallenge extends KrbSequenceType {
- private static int TOKENINFOS = 0;
-
- static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
- new Asn1FieldInfo(TOKENINFOS, TokenInfos.class)
- };
-
- public PaTokenChallenge() {
- super(fieldInfos);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/PaTokenRequest.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/PaTokenRequest.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/PaTokenRequest.java
deleted file mode 100644
index 7e138b6..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/PaTokenRequest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.pa.token;
-
-import org.apache.haox.asn1.type.Asn1FieldInfo;
-import org.apache.kerberos.kerb.spec.KrbSequenceType;
-import org.apache.kerberos.kerb.spec.common.KrbToken;
-
-/**
- PA-TOKEN-REQUEST ::= SEQUENCE {
- token [0] OCTET STRING,
- tokenInfo [1] TokenInfo
- }
-*/
-public class PaTokenRequest extends KrbSequenceType {
- private static int TOKEN_INFO = 0;
- private static int TOKEN = 1;
-
- static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
- new Asn1FieldInfo(TOKEN_INFO, TokenInfo.class),
- new Asn1FieldInfo(TOKEN, KrbToken.class)
- };
-
- public PaTokenRequest() {
- super(fieldInfos);
- }
-
- public KrbToken getToken() {
- return getFieldAs(TOKEN, KrbToken.class);
- }
-
- public void setToken(KrbToken token) {
- setFieldAs(TOKEN, token);
- }
-
- public String getTokenInfo() {
- return getFieldAsString(TOKEN_INFO);
- }
-
- public void setTokenInfo(TokenInfo tokenInfo) {
- setFieldAs(TOKEN_INFO, tokenInfo);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenFlag.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenFlag.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenFlag.java
deleted file mode 100644
index dd5edd6..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenFlag.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.pa.token;
-
-import org.apache.kerberos.kerb.spec.KrbEnum;
-
-public enum TokenFlag implements KrbEnum {
- NONE(-1),
- ID_TOKEN_REQUIRED(0x40000000),
- AC_TOKEN_REQUIRED(0x20000000),
- BEARER_TOKEN_REQUIRED(0x10000000),
- HOK_TOKEN_REQUIRED(0x08000000);
-
- private final int value;
-
- private TokenFlag(int value) {
- this.value = value;
- }
-
- @Override
- public int getValue() {
- return value;
- }
-
- public static TokenFlag fromValue(int value) {
- for (KrbEnum e : values()) {
- if (e.getValue() == value) {
- return (TokenFlag) e;
- }
- }
-
- return NONE;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenFlags.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenFlags.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenFlags.java
deleted file mode 100644
index dde5ca7..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenFlags.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.pa.token;
-
-import org.apache.kerberos.kerb.spec.common.KrbFlags;
-
-import static org.apache.kerberos.kerb.spec.ticket.TicketFlag.INVALID;
-
-public class TokenFlags extends KrbFlags {
-
- public TokenFlags() {
- this(0);
- }
-
- public TokenFlags(int value) {
- setFlags(value);
- }
-
- public boolean isInvalid() {
- return isFlagSet(INVALID.getValue());
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenInfo.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenInfo.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenInfo.java
deleted file mode 100644
index d1e7067..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenInfo.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.pa.token;
-
-import org.apache.haox.asn1.type.Asn1FieldInfo;
-import org.apache.haox.asn1.type.Asn1OctetString;
-import org.apache.haox.asn1.type.Asn1Utf8String;
-import org.apache.kerberos.kerb.spec.KrbSequenceType;
-
-/**
- TokenInfo ::= SEQUENCE {
- flags [0] TokenFlags,
- tokenVendor [1] UTF8String,
- }
- */
-public class TokenInfo extends KrbSequenceType {
- private static int FLAGS = 0;
- private static int TOKEN_VENDOR = 1;
-
- static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
- new Asn1FieldInfo(FLAGS, Asn1OctetString.class, true),
- new Asn1FieldInfo(TOKEN_VENDOR, Asn1Utf8String.class),
- };
-
- public TokenInfo() {
- super(fieldInfos);
- }
-
- public TokenFlags getFlags() {
- return getFieldAs(FLAGS, TokenFlags.class);
- }
-
- public void setFlags(TokenFlags flags) {
- setFieldAs(FLAGS, flags);
- }
-
- public String getTokenVendor() {
- return getFieldAsString(TOKEN_VENDOR);
- }
-
- public void setTokenVendor(String tokenVendor) {
- setFieldAs(TOKEN_VENDOR, new Asn1Utf8String(tokenVendor));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenInfos.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenInfos.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenInfos.java
deleted file mode 100644
index 127213c..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/pa/token/TokenInfos.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.pa.token;
-
-import org.apache.kerberos.kerb.spec.KrbSequenceOfType;
-
-/**
- SEQUENCE (SIZE(1..MAX)) OF TokenInfo,
-*/
-public class TokenInfos extends KrbSequenceOfType<TokenInfo> {
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/AbstractServiceTicket.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/AbstractServiceTicket.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/AbstractServiceTicket.java
deleted file mode 100644
index b8f7a55..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/AbstractServiceTicket.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.ticket;
-
-import org.apache.kerberos.kerb.spec.common.EncryptionKey;
-import org.apache.kerberos.kerb.spec.kdc.EncKdcRepPart;
-
-public class AbstractServiceTicket {
- private Ticket ticket;
- private EncKdcRepPart encKdcRepPart;
-
- public AbstractServiceTicket(Ticket ticket, EncKdcRepPart encKdcRepPart) {
- this.ticket = ticket;
- this.encKdcRepPart = encKdcRepPart;
- }
-
- public Ticket getTicket() {
- return ticket;
- }
-
- public EncKdcRepPart getEncKdcRepPart() {
- return encKdcRepPart;
- }
-
- public EncryptionKey getSessionKey() {
- return encKdcRepPart.getKey();
- }
-
- public String getRealm() {
- return ticket.getRealm();
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/EncTicketPart.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/EncTicketPart.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/EncTicketPart.java
deleted file mode 100644
index b5599ed..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/EncTicketPart.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.ticket;
-
-import org.apache.haox.asn1.type.Asn1FieldInfo;
-import org.apache.kerberos.kerb.spec.KerberosString;
-import org.apache.kerberos.kerb.spec.KerberosTime;
-import org.apache.kerberos.kerb.spec.KrbAppSequenceType;
-import org.apache.kerberos.kerb.spec.common.*;
-
-/**
- -- Encrypted part of ticket
- EncTicketPart ::= [APPLICATION 3] SEQUENCE {
- flags [0] TicketFlags,
- key [1] EncryptionKey,
- crealm [2] Realm,
- cname [3] PrincipalName,
- transited [4] TransitedEncoding,
- authtime [5] KerberosTime,
- starttime [6] KerberosTime OPTIONAL,
- endtime [7] KerberosTime,
- renew-till [8] KerberosTime OPTIONAL,
- caddr [9] HostAddresses OPTIONAL,
- authorization-data [10] AuthorizationData OPTIONAL
- }
- */
-public class EncTicketPart extends KrbAppSequenceType {
- public static final int TAG = 3;
-
- private static int FLAGS = 0;
- private static int KEY = 1;
- private static int CREALM = 2;
- private static int CNAME = 3;
- private static int TRANSITED = 4;
- private static int AUTHTIME = 5;
- private static int STARTTIME = 6;
- private static int ENDTIME = 7;
- private static int RENEW_TILL = 8;
- private static int CADDR = 9;
- private static int AUTHORIZATION_DATA = 10;
-
- static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
- new Asn1FieldInfo(FLAGS, 0, TicketFlags.class),
- new Asn1FieldInfo(KEY, 1, EncryptionKey.class),
- new Asn1FieldInfo(CREALM, 2, KerberosString.class),
- new Asn1FieldInfo(CNAME, 3, PrincipalName.class),
- new Asn1FieldInfo(TRANSITED, 4, TransitedEncoding.class),
- new Asn1FieldInfo(AUTHTIME, 5, KerberosTime.class),
- new Asn1FieldInfo(STARTTIME, 6, KerberosTime.class),
- new Asn1FieldInfo(ENDTIME, 7, KerberosTime.class),
- new Asn1FieldInfo(ENDTIME, 8, KerberosTime.class),
- new Asn1FieldInfo(CADDR, 9, HostAddresses.class),
- new Asn1FieldInfo(AUTHORIZATION_DATA, 10, AuthorizationData.class)
- };
-
- public EncTicketPart() {
- super(TAG, fieldInfos);
- }
-
- public TicketFlags getFlags() {
- return getFieldAs(FLAGS, TicketFlags.class);
- }
-
- public void setFlags(TicketFlags flags) {
- setFieldAs(FLAGS, flags);
- }
-
- public EncryptionKey getKey() {
- return getFieldAs(KEY, EncryptionKey.class);
- }
-
- public void setKey(EncryptionKey key) {
- setFieldAs(KEY, key);
- }
-
- public String getCrealm() {
- return getFieldAsString(CREALM);
- }
-
- public void setCrealm(String crealm) {
- setFieldAsString(CREALM, crealm);
- }
-
- public PrincipalName getCname() {
- return getFieldAs(CNAME, PrincipalName.class);
- }
-
- public void setCname(PrincipalName cname) {
- setFieldAs(CNAME, cname);
- }
-
- public TransitedEncoding getTransited() {
- return getFieldAs(TRANSITED, TransitedEncoding.class);
- }
-
- public void setTransited(TransitedEncoding transited) {
- setFieldAs(TRANSITED, transited);
- }
-
- public KerberosTime getAuthTime() {
- return getFieldAs(AUTHTIME, KerberosTime.class);
- }
-
- public void setAuthTime(KerberosTime authTime) {
- setFieldAs(AUTHTIME, authTime);
- }
-
- public KerberosTime getStartTime() {
- return getFieldAs(STARTTIME, KerberosTime.class);
- }
-
- public void setStartTime(KerberosTime startTime) {
- setFieldAs(STARTTIME, startTime);
- }
-
- public KerberosTime getEndTime() {
- return getFieldAs(ENDTIME, KerberosTime.class);
- }
-
- public void setEndTime(KerberosTime endTime) {
- setFieldAs(ENDTIME, endTime);
- }
-
- public KerberosTime getRenewtill() {
- return getFieldAs(RENEW_TILL, KerberosTime.class);
- }
-
- public void setRenewtill(KerberosTime renewtill) {
- setFieldAs(RENEW_TILL, renewtill);
- }
-
- public HostAddresses getClientAddresses() {
- return getFieldAs(CADDR, HostAddresses.class);
- }
-
- public void setClientAddresses(HostAddresses clientAddresses) {
- setFieldAs(CADDR, clientAddresses);
- }
-
- public AuthorizationData getAuthorizationData() {
- return getFieldAs(AUTHORIZATION_DATA, AuthorizationData.class);
- }
-
- public void setAuthorizationData(AuthorizationData authorizationData) {
- setFieldAs(AUTHORIZATION_DATA, authorizationData);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/ServiceTicket.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/ServiceTicket.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/ServiceTicket.java
deleted file mode 100644
index 1475440..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/ServiceTicket.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.ticket;
-
-import org.apache.kerberos.kerb.spec.kdc.EncTgsRepPart;
-
-public class ServiceTicket extends AbstractServiceTicket {
- public ServiceTicket(Ticket ticket, EncTgsRepPart encKdcRepPart) {
- super(ticket, encKdcRepPart);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TgtTicket.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TgtTicket.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TgtTicket.java
deleted file mode 100644
index 592b8e3..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TgtTicket.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.ticket;
-
-import org.apache.kerberos.kerb.spec.common.PrincipalName;
-import org.apache.kerberos.kerb.spec.kdc.EncAsRepPart;
-
-public class TgtTicket extends AbstractServiceTicket {
- private PrincipalName clientPrincipal;
-
- public TgtTicket(Ticket ticket, EncAsRepPart encKdcRepPart, String clientPrincipal) {
- super(ticket, encKdcRepPart);
- this.clientPrincipal = new PrincipalName(clientPrincipal);
- }
-
- public PrincipalName getClientPrincipal() {
- return clientPrincipal;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/Ticket.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/Ticket.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/Ticket.java
deleted file mode 100644
index 504ff5f..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/Ticket.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.ticket;
-
-import org.apache.haox.asn1.type.Asn1FieldInfo;
-import org.apache.haox.asn1.type.Asn1Integer;
-import org.apache.kerberos.kerb.KrbConstant;
-import org.apache.kerberos.kerb.spec.KerberosString;
-import org.apache.kerberos.kerb.spec.KrbAppSequenceType;
-import org.apache.kerberos.kerb.spec.common.EncryptedData;
-import org.apache.kerberos.kerb.spec.common.PrincipalName;
-
-/**
- Ticket ::= [APPLICATION 1] SEQUENCE {
- tkt-vno [0] INTEGER (5),
- realm [1] Realm,
- sname [2] PrincipalName,
- enc-part [3] EncryptedData -- EncTicketPart
- }
- */
-public class Ticket extends KrbAppSequenceType {
- public static final int TKT_KVNO = KrbConstant.KRB_V5;
- public static final int TAG = 1;
-
- private static int TKT_VNO = 0;
- private static int REALM = 1;
- private static int SNAME = 2;
- private static int ENC_PART = 3;
-
- static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
- new Asn1FieldInfo(TKT_VNO, 0, Asn1Integer.class),
- new Asn1FieldInfo(REALM, 1, KerberosString.class),
- new Asn1FieldInfo(SNAME, 2, PrincipalName.class),
- new Asn1FieldInfo(ENC_PART, 3, EncryptedData.class)
- };
-
- public Ticket() {
- super(TAG, fieldInfos);
- setTktKvno(TKT_KVNO);
- }
-
- private EncTicketPart encPart;
-
- public int getTktvno() {
- return getFieldAsInt(TKT_VNO);
- }
-
- public void setTktKvno(int kvno) {
- setFieldAsInt(TKT_VNO, kvno);
- }
- public PrincipalName getSname() {
- return getFieldAs(SNAME, PrincipalName.class);
- }
-
- public void setSname(PrincipalName sname) {
- setFieldAs(SNAME, sname);
- }
-
- public String getRealm() {
- return getFieldAsString(REALM);
- }
-
- public void setRealm(String realm) {
- setFieldAs(REALM, new KerberosString(realm));
- }
-
- public EncryptedData getEncryptedEncPart() {
- return getFieldAs(ENC_PART, EncryptedData.class);
- }
-
- public void setEncryptedEncPart(EncryptedData encryptedEncPart) {
- setFieldAs(ENC_PART, encryptedEncPart);
- }
-
- public EncTicketPart getEncPart() {
- return encPart;
- }
-
- public void setEncPart(EncTicketPart encPart) {
- this.encPart = encPart;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TicketFlag.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TicketFlag.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TicketFlag.java
deleted file mode 100644
index 4aec901..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TicketFlag.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.ticket;
-
-import org.apache.kerberos.kerb.spec.KrbEnum;
-
-public enum TicketFlag implements KrbEnum {
- NONE(-1),
- FORWARDABLE(0x40000000),
- FORWARDED(0x20000000),
- PROXIABLE(0x10000000),
- PROXY(0x08000000),
- MAY_POSTDATE(0x04000000),
- POSTDATED(0x02000000),
- INVALID(0x01000000),
- RENEWABLE(0x00800000),
- INITIAL(0x00400000),
- PRE_AUTH(0x00200000),
- HW_AUTH(0x00100000),
- TRANSIT_POLICY_CHECKED( 0x00080000),
- OK_AS_DELEGATE(0x00040000),
- ENC_PA_REP(0x00010000),
- ANONYMOUS(0x00008000);
-
- private final int value;
-
- private TicketFlag(int value) {
- this.value = value;
- }
-
- @Override
- public int getValue() {
- return value;
- }
-
- public static TicketFlag fromValue(int value) {
- for (KrbEnum e : values()) {
- if (e.getValue() == value) {
- return (TicketFlag) e;
- }
- }
-
- return NONE;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TicketFlags.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TicketFlags.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TicketFlags.java
deleted file mode 100644
index c81d53f..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/TicketFlags.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.ticket;
-
-import org.apache.kerberos.kerb.spec.common.KrbFlags;
-
-import static org.apache.kerberos.kerb.spec.ticket.TicketFlag.INVALID;
-
-public class TicketFlags extends KrbFlags {
-
- public TicketFlags() {
- this(0);
- }
-
- public TicketFlags(int value) {
- setFlags(value);
- }
-
- public boolean isInvalid() {
- return isFlagSet(INVALID.getValue());
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/Tickets.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/Tickets.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/Tickets.java
deleted file mode 100644
index f4d04b5..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/ticket/Tickets.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.ticket;
-
-import org.apache.kerberos.kerb.spec.KrbSequenceOfType;
-
-/**
- SEQUENCE OF Ticket
- */
-public class Tickets extends KrbSequenceOfType<Ticket> {
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/x509/AlgorithmIdentifier.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/x509/AlgorithmIdentifier.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/x509/AlgorithmIdentifier.java
deleted file mode 100644
index 86f3c6c..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/x509/AlgorithmIdentifier.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.x509;
-
-import org.apache.haox.asn1.type.*;
-
-/**
- AlgorithmIdentifier ::= SEQUENCE {
- algorithm OBJECT IDENTIFIER,
- parameters ANY DEFINED BY algorithm OPTIONAL
- }
- */
-public class AlgorithmIdentifier extends Asn1SequenceType {
- private static int ALGORITHM = 0;
- private static int PARAMETERS = 1;
-
- static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
- new Asn1FieldInfo(ALGORITHM, -1, Asn1ObjectIdentifier.class),
- new Asn1FieldInfo(PARAMETERS, -1, Asn1Any.class)
- };
-
- public AlgorithmIdentifier() {
- super(fieldInfos);
- }
-
- public Asn1ObjectIdentifier getAlgorithm() {
- return getFieldAs(ALGORITHM, Asn1ObjectIdentifier.class);
- }
-
- public void setAlgorithm(Asn1ObjectIdentifier algorithm) {
- setFieldAs(ALGORITHM, algorithm);
- }
-
- public Asn1Type getParameters() {
- return getFieldAsAny(PARAMETERS);
- }
-
- public void setParameters(Asn1Type parameters) {
- setFieldAsAny(PARAMETERS, parameters);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/x509/SubjectPublicKeyInfo.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/x509/SubjectPublicKeyInfo.java b/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/x509/SubjectPublicKeyInfo.java
deleted file mode 100644
index cf49990..0000000
--- a/haox-kerb/kerb-core/src/main/java/org/apache/kerberos/kerb/spec/x509/SubjectPublicKeyInfo.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.spec.x509;
-
-import org.apache.haox.asn1.type.Asn1BitString;
-import org.apache.haox.asn1.type.Asn1FieldInfo;
-import org.apache.haox.asn1.type.Asn1SequenceType;
-
-/**
- SubjectPublicKeyInfo ::= SEQUENCE {
- algorithm AlgorithmIdentifier,
- subjectPublicKey BIT STRING
- }
- */
-public class SubjectPublicKeyInfo extends Asn1SequenceType {
- private static int ALGORITHM = 0;
- private static int SUBJECT_PUBLIC_KEY = 1;
-
- static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
- new Asn1FieldInfo(ALGORITHM, -1, AlgorithmIdentifier.class),
- new Asn1FieldInfo(SUBJECT_PUBLIC_KEY, -1, Asn1BitString.class)
- };
-
- public SubjectPublicKeyInfo() {
- super(fieldInfos);
- }
-
- public AlgorithmIdentifier getAlgorithm() {
- return getFieldAs(ALGORITHM, AlgorithmIdentifier.class);
- }
-
- public void setAlgorithm(AlgorithmIdentifier algorithm) {
- setFieldAs(ALGORITHM, algorithm);
- }
-
- public byte[] getSubjectPubKey() {
- return getFieldAsOctets(SUBJECT_PUBLIC_KEY);
- }
-
- public void setSubjectPubKey(byte[] subjectPubKey) {
- setFieldAs(SUBJECT_PUBLIC_KEY, new Asn1BitString(subjectPubKey));
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-crypto/pom.xml
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/pom.xml b/haox-kerb/kerb-crypto/pom.xml
deleted file mode 100644
index aee0762..0000000
--- a/haox-kerb/kerb-crypto/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. See accompanying LICENSE file.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.haox</groupId>
- <artifactId>haox-kerb</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>kerb-crypto</artifactId>
-
- <name>Haox-kerb Crypto</name>
- <description>Haox-kerb Crypto facility</description>
-
- <dependencies>
- <dependency>
- <groupId>org.haox</groupId>
- <artifactId>haox-util</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.haox</groupId>
- <artifactId>kerb-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/AbstractCryptoTypeHandler.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/AbstractCryptoTypeHandler.java b/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/AbstractCryptoTypeHandler.java
deleted file mode 100644
index 0ee9a49..0000000
--- a/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/AbstractCryptoTypeHandler.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.crypto;
-
-import org.apache.kerberos.kerb.crypto.cksum.HashProvider;
-import org.apache.kerberos.kerb.crypto.enc.EncryptProvider;
-
-import java.util.Arrays;
-
-public abstract class AbstractCryptoTypeHandler implements CryptoTypeHandler {
-
- private EncryptProvider encProvider;
- private HashProvider hashProvider;
-
- public AbstractCryptoTypeHandler(EncryptProvider encProvider,
- HashProvider hashProvider) {
- this.encProvider = encProvider;
- this.hashProvider = hashProvider;
- }
-
- @Override
- public EncryptProvider encProvider() {
- return encProvider;
- }
-
- @Override
- public HashProvider hashProvider() {
- return hashProvider;
- }
-
- protected static boolean checksumEqual(byte[] cksum1, byte[] cksum2) {
- return Arrays.equals(cksum1, cksum2);
- }
-
- protected static boolean checksumEqual(byte[] cksum1, byte[] cksum2, int cksum2Start, int len) {
- if (cksum1 == cksum2)
- return true;
- if (cksum1 == null || cksum2 == null)
- return false;
-
- if (len <= cksum2.length && len <= cksum1.length) {
- for (int i = 0; i < len; i++)
- if (cksum1[i] != cksum2[cksum2Start + i])
- return false;
- } else {
- return false;
- }
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/BytesUtil.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/BytesUtil.java b/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/BytesUtil.java
deleted file mode 100644
index b6ee367..0000000
--- a/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/BytesUtil.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.crypto;
-
-public class BytesUtil {
-
- public static short bytes2short(byte[] bytes, int offset, boolean bigEndian) {
- short val = 0;
-
- if (bigEndian) {
- val += (bytes[offset + 0] & 0xff) << 8;
- val += (bytes[offset + 1] & 0xff);
- } else {
- val += (bytes[offset + 1] & 0xff) << 8;
- val += (bytes[offset + 0] & 0xff);
- }
-
- return val;
- }
-
- public static short bytes2short(byte[] bytes, boolean bigEndian) {
- return bytes2short(bytes, 0, bigEndian);
- }
-
- public static byte[] short2bytes(int val, boolean bigEndian) {
- byte[] bytes = new byte[2];
-
- short2bytes(val, bytes, 0, bigEndian);
-
- return bytes;
- }
-
- public static void short2bytes(int val, byte[] bytes, int offset, boolean bigEndian) {
- if (bigEndian) {
- bytes[offset + 0] = (byte) ((val >> 8) & 0xff);
- bytes[offset + 1] = (byte) ((val) & 0xff);
- } else {
- bytes[offset + 1] = (byte) ((val >> 8) & 0xff);
- bytes[offset + 0] = (byte) ((val ) & 0xff);
- }
- }
-
- public static int bytes2int(byte[] bytes, boolean bigEndian) {
- return bytes2int(bytes, 0, bigEndian);
- }
-
- public static int bytes2int(byte[] bytes, int offset, boolean bigEndian) {
- int val = 0;
-
- if (bigEndian) {
- val += (bytes[offset + 0] & 0xff) << 24;
- val += (bytes[offset + 1] & 0xff) << 16;
- val += (bytes[offset + 2] & 0xff) << 8;
- val += (bytes[offset + 3] & 0xff);
- } else {
- val += (bytes[offset + 3] & 0xff) << 24;
- val += (bytes[offset + 2] & 0xff) << 16;
- val += (bytes[offset + 1] & 0xff) << 8;
- val += (bytes[offset + 0] & 0xff);
- }
-
- return val;
- }
-
- public static byte[] int2bytes(int val, boolean bigEndian) {
- byte[] bytes = new byte[4];
-
- int2bytes(val, bytes, 0, bigEndian);
-
- return bytes;
- }
-
- public static void int2bytes(int val, byte[] bytes, int offset, boolean bigEndian) {
- if (bigEndian) {
- bytes[offset + 0] = (byte) ((val >> 24) & 0xff);
- bytes[offset + 1] = (byte) ((val >> 16) & 0xff);
- bytes[offset + 2] = (byte) ((val >> 8) & 0xff);
- bytes[offset + 3] = (byte) ((val) & 0xff);
- } else {
- bytes[offset + 3] = (byte) ((val >> 24) & 0xff);
- bytes[offset + 2] = (byte) ((val >> 16) & 0xff);
- bytes[offset + 1] = (byte) ((val >> 8) & 0xff);
- bytes[offset + 0] = (byte) ((val) & 0xff);
- }
- }
-
- public static byte[] long2bytes(long val, boolean bigEndian) {
- byte[] bytes = new byte[8];
- long2bytes(val, bytes, 0, bigEndian);
- return bytes;
- }
-
- public static void long2bytes(long val, byte[] bytes, int offset, boolean bigEndian) {
- if (bigEndian) {
- for (int i = 0; i < 8; i++) {
- bytes[i + offset] = (byte) ((val >> ((7 - i) * 8)) & 0xffL);
- }
- } else {
- for (int i = 0; i < 8; i++) {
- bytes[i + offset] = (byte) ((val >> (i * 8)) & 0xffL);
- }
- }
- }
-
- public static long bytes2long(byte[] bytes, boolean bigEndian) {
- return bytes2long(bytes, 0, bigEndian);
- }
-
- public static long bytes2long(byte[] bytes, int offset, boolean bigEndian) {
- long val = 0;
-
- if (bigEndian) {
- for (int i = 0; i < 8; i++) {
- val |= (((long) bytes[i + offset]) & 0xffL) << ((7 - i) * 8);
- }
- } else {
- for (int i = 0; i < 8; i++) {
- val |= (((long) bytes[i + offset]) & 0xffL) << (i * 8);
- }
- }
-
- return val;
- }
-
- public static byte[] padding(byte[] data, int block) {
- int len = data.length;
- int paddingLen = len % block != 0 ? 8 - len % block : 0;
- if (paddingLen == 0) {
- return data;
- }
-
- byte[] result = new byte[len + + paddingLen];
- System.arraycopy(data, 0, result, 0, len);
- return result;
- }
-
- public static byte[] duplicate(byte[] bytes) {
- return duplicate(bytes, 0, bytes.length);
- }
-
- public static byte[] duplicate(byte[] bytes, int offset, int len) {
- byte[] dup = new byte[len];
- System.arraycopy(bytes, offset, dup, 0, len);
- return dup;
- }
-
- public static void xor(byte[] input, int offset, byte[] output) {
- int a, b;
- for (int i = 0; i < output.length / 4; ++i) {
- a = BytesUtil.bytes2int(input, offset + i * 4, true);
- b = BytesUtil.bytes2int(output, i * 4, true);
- b = a ^ b;
- BytesUtil.int2bytes(b, output, i * 4, true);
- }
- }
-
- public static void xor(byte[] a, byte[] b, byte[] output) {
- int av, bv, v;
- for (int i = 0; i < a.length / 4; ++i) {
- av = BytesUtil.bytes2int(a, i * 4, true);
- bv = BytesUtil.bytes2int(b, i * 4, true);
- v = av ^ bv;
- BytesUtil.int2bytes(v, output, i * 4, true);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/Camellia.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/Camellia.java b/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/Camellia.java
deleted file mode 100644
index e44ae86..0000000
--- a/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/Camellia.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.crypto;
-
-/**
- * Camellia - based on RFC 3713, about half the size of CamelliaEngine.
- *
- * This is based on CamelliaEngine.java from bouncycastle library.
- */
-
-public class Camellia {
- private static final int BLOCK_SIZE = 16;
- private int[] state = new int[4]; // for encryption and decryption
-
- private CamelliaKey camKey;
-
- public void setKey(boolean forEncryption, byte[] key) {
- camKey = new CamelliaKey(key, forEncryption);
- }
-
- private void process128Block(byte[] in, int inOff,
- byte[] out, int outOff) {
- for (int i = 0; i < 4; i++) {
- state[i] = BytesUtil.bytes2int(in, inOff + (i * 4), true);
- state[i] ^= camKey.kw[i];
- }
-
- camKey.f2(state, camKey.subkey, 0);
- camKey.f2(state, camKey.subkey, 4);
- camKey.f2(state, camKey.subkey, 8);
- camKey.fls(state, camKey.ke, 0);
- camKey.f2(state, camKey.subkey, 12);
- camKey.f2(state, camKey.subkey, 16);
- camKey.f2(state, camKey.subkey, 20);
- camKey.fls(state, camKey.ke, 4);
- camKey.f2(state, camKey.subkey, 24);
- camKey.f2(state, camKey.subkey, 28);
- camKey.f2(state, camKey.subkey, 32);
-
- state[2] ^= camKey.kw[4];
- state[3] ^= camKey.kw[5];
- state[0] ^= camKey.kw[6];
- state[1] ^= camKey.kw[7];
-
- BytesUtil.int2bytes(state[2], out, outOff, true);
- BytesUtil.int2bytes(state[3], out, outOff + 4, true);
- BytesUtil.int2bytes(state[0], out, outOff + 8, true);
- BytesUtil.int2bytes(state[1], out, outOff + 12, true);
- }
-
- private void processBlockLargerBlock(byte[] in, int inOff,
- byte[] out, int outOff) {
- for (int i = 0; i < 4; i++) {
- state[i] = BytesUtil.bytes2int(in, inOff + (i * 4), true);
- state[i] ^= camKey.kw[i];
- }
-
- camKey.f2(state, camKey.subkey, 0);
- camKey.f2(state, camKey.subkey, 4);
- camKey.f2(state, camKey.subkey, 8);
- camKey.fls(state, camKey.ke, 0);
- camKey.f2(state, camKey.subkey, 12);
- camKey.f2(state, camKey.subkey, 16);
- camKey.f2(state, camKey.subkey, 20);
- camKey.fls(state, camKey.ke, 4);
- camKey.f2(state, camKey.subkey, 24);
- camKey.f2(state, camKey.subkey, 28);
- camKey.f2(state, camKey.subkey, 32);
- camKey.fls(state, camKey.ke, 8);
- camKey.f2(state, camKey.subkey, 36);
- camKey.f2(state, camKey.subkey, 40);
- camKey.f2(state, camKey.subkey, 44);
-
- state[2] ^= camKey.kw[4];
- state[3] ^= camKey.kw[5];
- state[0] ^= camKey.kw[6];
- state[1] ^= camKey.kw[7];
-
- BytesUtil.int2bytes(state[2], out, outOff, true);
- BytesUtil.int2bytes(state[3], out, outOff + 4, true);
- BytesUtil.int2bytes(state[0], out, outOff + 8, true);
- BytesUtil.int2bytes(state[1], out, outOff + 12, true);
- }
-
- public void processBlock(byte[] in, int inOff) {
- byte[] out = new byte[BLOCK_SIZE];
-
- if (camKey.is128()) {
- process128Block(in, inOff, out, 0);
- } else {
- processBlockLargerBlock(in, inOff, out, 0);
- }
-
- System.arraycopy(out, 0, in, inOff, BLOCK_SIZE);
- }
-
- public void encrypt(byte[] data, byte[] iv) {
- byte[] cipher = new byte[BLOCK_SIZE];
- byte[] cipherState = new byte[BLOCK_SIZE];
-
- int blocksNum = (data.length + BLOCK_SIZE - 1) / BLOCK_SIZE;
- int lastBlockLen = data.length - (blocksNum - 1) * BLOCK_SIZE;
- if (blocksNum == 1) {
- cbcEnc(data, 0, 1, cipherState);
- return;
- }
-
- if (iv != null) {
- System.arraycopy(iv, 0, cipherState, 0, BLOCK_SIZE);
- }
-
- int contBlocksNum, offset = 0;
- while (blocksNum > 2) {
- contBlocksNum = (data.length - offset) / BLOCK_SIZE;
- if (contBlocksNum > 0) {
- // Encrypt a series of contiguous blocks in place if we can, but
- // don't touch the last two blocks.
- contBlocksNum = (contBlocksNum > blocksNum - 2) ? blocksNum - 2 : contBlocksNum;
- cbcEnc(data, offset, contBlocksNum, cipherState);
- offset += contBlocksNum * BLOCK_SIZE;
- blocksNum -= contBlocksNum;
- } else {
- cbcEnc(data, offset, 1, cipherState);
- offset += BLOCK_SIZE;
- blocksNum--;
- }
- }
-
- // Encrypt the last two blocks and store the results in reverse order
- byte[] blockN2 = new byte[BLOCK_SIZE];
- byte[] blockN1 = new byte[BLOCK_SIZE];
-
- System.arraycopy(data, offset, blockN2, 0, BLOCK_SIZE);
- cbcEnc(blockN2, 0, 1, cipherState);
- System.arraycopy(data, offset + BLOCK_SIZE, blockN1, 0, lastBlockLen);
- cbcEnc(blockN1, 0, 1, cipherState);
-
- System.arraycopy(blockN1, 0, data, offset, BLOCK_SIZE);
- System.arraycopy(blockN2, 0, data, offset + BLOCK_SIZE, lastBlockLen);
-
- if (iv != null) {
- System.arraycopy(cipherState, 0, iv, 0, BLOCK_SIZE);
- }
- }
-
- public void decrypt(byte[] data, byte[] iv) {
- byte[] cipher = new byte[BLOCK_SIZE];
- byte[] cipherState = new byte[BLOCK_SIZE];
-
- int blocksNum = (data.length + BLOCK_SIZE - 1) / BLOCK_SIZE;
- int lastBlockLen = data.length - (blocksNum - 1) * BLOCK_SIZE;
- if (blocksNum == 1) {
- cbcDec(data, 0, 1, cipherState);
- return;
- }
-
- if (iv != null) {
- System.arraycopy(iv, 0, cipherState, 0, BLOCK_SIZE);
- }
-
- int contBlocksNum, offset = 0;
- while (blocksNum > 2) {
- contBlocksNum = (data.length - offset) / BLOCK_SIZE;
- if (contBlocksNum > 0) {
- // Decrypt a series of contiguous blocks in place if we can, but
- // don't touch the last two blocks.
- contBlocksNum = (contBlocksNum > blocksNum - 2) ? blocksNum - 2 : contBlocksNum;
- cbcDec(data, offset, contBlocksNum, cipherState);
- offset += contBlocksNum * BLOCK_SIZE;
- blocksNum -= contBlocksNum;
- } else {
- cbcDec(data, offset, 1, cipherState);
- offset += BLOCK_SIZE;
- blocksNum--;
- }
- }
-
- // Decrypt the last two blocks
- byte[] blockN2 = new byte[BLOCK_SIZE];
- byte[] blockN1 = new byte[BLOCK_SIZE];
- System.arraycopy(data, offset, blockN2, 0, BLOCK_SIZE);
- System.arraycopy(data, offset + BLOCK_SIZE, blockN1, 0, lastBlockLen);
- if (iv != null) {
- System.arraycopy(blockN2, 0, iv, 0, BLOCK_SIZE);
- }
-
- byte[] tmpCipherState = new byte[BLOCK_SIZE];
- System.arraycopy(blockN1, 0, tmpCipherState, 0, BLOCK_SIZE);
- cbcDec(blockN2, 0, 1, tmpCipherState);
- System.arraycopy(blockN2, lastBlockLen, blockN1, lastBlockLen, BLOCK_SIZE - lastBlockLen);
- cbcDec(blockN1, 0, 1, cipherState);
-
- System.arraycopy(blockN1, 0, data, offset, BLOCK_SIZE);
- System.arraycopy(blockN2, 0, data, offset + BLOCK_SIZE, lastBlockLen);
- }
-
- /**
- * CBC encrypt nblocks blocks of data in place, using and updating iv.
- */
- public void cbcEnc(byte[] data, int offset, int blocksNum, byte[] cipherState) {
- byte[] cipher = new byte[BLOCK_SIZE];
- for (int i = 0; i < blocksNum; ++i) {
- System.arraycopy(data, offset + i * BLOCK_SIZE, cipher, 0, BLOCK_SIZE);
- BytesUtil.xor(cipherState, 0, cipher);
- processBlock(cipher, 0);
- System.arraycopy(cipher, 0, data, offset + i * BLOCK_SIZE, BLOCK_SIZE);
- System.arraycopy(cipher, 0, cipherState, 0, BLOCK_SIZE);
- }
- }
-
- /**
- * CBC encrypt nblocks blocks of data in place, using and updating iv.
- */
- public void cbcDec(byte[] data, int offset, int blocksNum, byte[] cipherState) {
- byte[] lastBlock = new byte[BLOCK_SIZE];
- byte[] cipher = new byte[BLOCK_SIZE];
-
- System.arraycopy(data, offset + (blocksNum - 1) * BLOCK_SIZE, lastBlock, 0, BLOCK_SIZE);
- for (int i = blocksNum; i > 0; i--) {
- System.arraycopy(data, offset + (i - 1) * BLOCK_SIZE, cipher, 0, BLOCK_SIZE);
- processBlock(cipher, 0);
-
- if (i == 1) {
- BytesUtil.xor(cipherState, 0, cipher);
- } else {
- BytesUtil.xor(data, offset + (i - 2) * BLOCK_SIZE, cipher);
- }
-
- System.arraycopy(cipher, 0, data, offset + (i - 1) * BLOCK_SIZE, BLOCK_SIZE);
- }
- System.arraycopy(lastBlock, 0, cipherState, 0, BLOCK_SIZE);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/CamelliaKey.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/CamelliaKey.java b/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/CamelliaKey.java
deleted file mode 100644
index 0f35d62..0000000
--- a/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/CamelliaKey.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.crypto;
-
-/**
- * Camellia - based on RFC 3713, about half the size of CamelliaEngine.
- *
- * This is based on CamelliaEngine.java from bouncycastle library.
- */
-
-public class CamelliaKey {
- private int keySize;
-
- protected int[] subkey = new int[24 * 4];
- protected int[] kw = new int[4 * 2]; // for whitening
- protected int[] ke = new int[6 * 2]; // for FL and FL^(-1)
-
- private static final int SIGMA[] = {
- 0xa09e667f, 0x3bcc908b,
- 0xb67ae858, 0x4caa73b2,
- 0xc6ef372f, 0xe94f82be,
- 0x54ff53a5, 0xf1d36f1c,
- 0x10e527fa, 0xde682d1d,
- 0xb05688c2, 0xb3e6c1fd
- };
-
- // S-box data
- protected static final byte SBOX1[] = {
- (byte)112, (byte)130, (byte)44, (byte)236,
- (byte)179, (byte)39, (byte)192, (byte)229,
- (byte)228, (byte)133, (byte)87, (byte)53,
- (byte)234, (byte)12, (byte)174, (byte)65,
- (byte)35, (byte)239, (byte)107, (byte)147,
- (byte)69, (byte)25, (byte)165, (byte)33,
- (byte)237, (byte)14, (byte)79, (byte)78,
- (byte)29, (byte)101, (byte)146, (byte)189,
- (byte)134, (byte)184, (byte)175, (byte)143,
- (byte)124, (byte)235, (byte)31, (byte)206,
- (byte)62, (byte)48, (byte)220, (byte)95,
- (byte)94, (byte)197, (byte)11, (byte)26,
- (byte)166, (byte)225, (byte)57, (byte)202,
- (byte)213, (byte)71, (byte)93, (byte)61,
- (byte)217, (byte)1, (byte)90, (byte)214,
- (byte)81, (byte)86, (byte)108, (byte)77,
- (byte)139, (byte)13, (byte)154, (byte)102,
- (byte)251, (byte)204, (byte)176, (byte)45,
- (byte)116, (byte)18, (byte)43, (byte)32,
- (byte)240, (byte)177, (byte)132, (byte)153,
- (byte)223, (byte)76, (byte)203, (byte)194,
- (byte)52, (byte)126, (byte)118, (byte)5,
- (byte)109, (byte)183, (byte)169, (byte)49,
- (byte)209, (byte)23, (byte)4, (byte)215,
- (byte)20, (byte)88, (byte)58, (byte)97,
- (byte)222, (byte)27, (byte)17, (byte)28,
- (byte)50, (byte)15, (byte)156, (byte)22,
- (byte)83, (byte)24, (byte)242, (byte)34,
- (byte)254, (byte)68, (byte)207, (byte)178,
- (byte)195, (byte)181, (byte)122, (byte)145,
- (byte)36, (byte)8, (byte)232, (byte)168,
- (byte)96, (byte)252, (byte)105, (byte)80,
- (byte)170, (byte)208, (byte)160, (byte)125,
- (byte)161, (byte)137, (byte)98, (byte)151,
- (byte)84, (byte)91, (byte)30, (byte)149,
- (byte)224, (byte)255, (byte)100, (byte)210,
- (byte)16, (byte)196, (byte)0, (byte)72,
- (byte)163, (byte)247, (byte)117, (byte)219,
- (byte)138, (byte)3, (byte)230, (byte)218,
- (byte)9, (byte)63, (byte)221, (byte)148,
- (byte)135, (byte)92, (byte)131, (byte)2,
- (byte)205, (byte)74, (byte)144, (byte)51,
- (byte)115, (byte)103, (byte)246, (byte)243,
- (byte)157, (byte)127, (byte)191, (byte)226,
- (byte)82, (byte)155, (byte)216, (byte)38,
- (byte)200, (byte)55, (byte)198, (byte)59,
- (byte)129, (byte)150, (byte)111, (byte)75,
- (byte)19, (byte)190, (byte)99, (byte)46,
- (byte)233, (byte)121, (byte)167, (byte)140,
- (byte)159, (byte)110, (byte)188, (byte)142,
- (byte)41, (byte)245, (byte)249, (byte)182,
- (byte)47, (byte)253, (byte)180, (byte)89,
- (byte)120, (byte)152, (byte)6, (byte)106,
- (byte)231, (byte)70, (byte)113, (byte)186,
- (byte)212, (byte)37, (byte)171, (byte)66,
- (byte)136, (byte)162, (byte)141, (byte)250,
- (byte)114, (byte)7, (byte)185, (byte)85,
- (byte)248, (byte)238, (byte)172, (byte)10,
- (byte)54, (byte)73, (byte)42, (byte)104,
- (byte)60, (byte)56, (byte)241, (byte)164,
- (byte)64, (byte)40, (byte)211, (byte)123,
- (byte)187, (byte)201, (byte)67, (byte)193,
- (byte)21, (byte)227, (byte)173, (byte)244,
- (byte)119, (byte)199, (byte)128, (byte)158
- };
-
- public CamelliaKey(byte[] key, boolean isEncrypt) {
- init(key, isEncrypt);
- }
-
- protected boolean is128() {
- return keySize == 16;
- }
-
- private static int rightRotate(int x, int s) {
- return (((x) >>> (s)) + ((x) << (32 - s)));
- }
-
- private static int leftRotate(int x, int s) {
- return ((x) << (s)) + ((x) >>> (32 - s));
- }
-
- private static void roldq(int rot, int[] ki, int ioff,
- int[] ko, int ooff) {
- ko[0 + ooff] = (ki[0 + ioff] << rot) | (ki[1 + ioff] >>> (32 - rot));
- ko[1 + ooff] = (ki[1 + ioff] << rot) | (ki[2 + ioff] >>> (32 - rot));
- ko[2 + ooff] = (ki[2 + ioff] << rot) | (ki[3 + ioff] >>> (32 - rot));
- ko[3 + ooff] = (ki[3 + ioff] << rot) | (ki[0 + ioff] >>> (32 - rot));
- ki[0 + ioff] = ko[0 + ooff];
- ki[1 + ioff] = ko[1 + ooff];
- ki[2 + ioff] = ko[2 + ooff];
- ki[3 + ioff] = ko[3 + ooff];
- }
-
- private static void decroldq(int rot, int[] ki, int ioff,
- int[] ko, int ooff) {
- ko[2 + ooff] = (ki[0 + ioff] << rot) | (ki[1 + ioff] >>> (32 - rot));
- ko[3 + ooff] = (ki[1 + ioff] << rot) | (ki[2 + ioff] >>> (32 - rot));
- ko[0 + ooff] = (ki[2 + ioff] << rot) | (ki[3 + ioff] >>> (32 - rot));
- ko[1 + ooff] = (ki[3 + ioff] << rot) | (ki[0 + ioff] >>> (32 - rot));
- ki[0 + ioff] = ko[2 + ooff];
- ki[1 + ioff] = ko[3 + ooff];
- ki[2 + ioff] = ko[0 + ooff];
- ki[3 + ioff] = ko[1 + ooff];
- }
-
- private static void roldqo32(int rot, int[] ki, int ioff,
- int[] ko, int ooff)
- {
- ko[0 + ooff] = (ki[1 + ioff] << (rot - 32)) | (ki[2 + ioff] >>> (64 - rot));
- ko[1 + ooff] = (ki[2 + ioff] << (rot - 32)) | (ki[3 + ioff] >>> (64 - rot));
- ko[2 + ooff] = (ki[3 + ioff] << (rot - 32)) | (ki[0 + ioff] >>> (64 - rot));
- ko[3 + ooff] = (ki[0 + ioff] << (rot - 32)) | (ki[1 + ioff] >>> (64 - rot));
- ki[0 + ioff] = ko[0 + ooff];
- ki[1 + ioff] = ko[1 + ooff];
- ki[2 + ioff] = ko[2 + ooff];
- ki[3 + ioff] = ko[3 + ooff];
- }
-
- private static void decroldqo32(int rot, int[] ki, int ioff,
- int[] ko, int ooff) {
- ko[2 + ooff] = (ki[1 + ioff] << (rot - 32)) | (ki[2 + ioff] >>> (64 - rot));
- ko[3 + ooff] = (ki[2 + ioff] << (rot - 32)) | (ki[3 + ioff] >>> (64 - rot));
- ko[0 + ooff] = (ki[3 + ioff] << (rot - 32)) | (ki[0 + ioff] >>> (64 - rot));
- ko[1 + ooff] = (ki[0 + ioff] << (rot - 32)) | (ki[1 + ioff] >>> (64 - rot));
- ki[0 + ioff] = ko[2 + ooff];
- ki[1 + ioff] = ko[3 + ooff];
- ki[2 + ioff] = ko[0 + ooff];
- ki[3 + ioff] = ko[1 + ooff];
- }
-
- private byte lRot8(byte v, int rot)
- {
- return (byte)((v << rot) | ((v & 0xff) >>> (8 - rot)));
- }
-
- private int sbox2(int x)
- {
- return (lRot8(SBOX1[x], 1) & 0xff);
- }
-
- private int sbox3(int x)
- {
- return (lRot8(SBOX1[x], 7) & 0xff);
- }
-
- private int sbox4(int x)
- {
- return (SBOX1[((int)lRot8((byte)x, 1) & 0xff)] & 0xff);
- }
-
- protected void fls(int[] s, int[] fkey, int keyoff) {
- s[1] ^= leftRotate(s[0] & fkey[0 + keyoff], 1);
- s[0] ^= fkey[1 + keyoff] | s[1];
-
- s[2] ^= fkey[3 + keyoff] | s[3];
- s[3] ^= leftRotate(fkey[2 + keyoff] & s[2], 1);
- }
-
- protected void f2(int[] s, int[] skey, int keyoff) {
- int t1, t2, u, v;
-
- t1 = s[0] ^ skey[0 + keyoff];
- u = sbox4((t1 & 0xff));
- u |= (sbox3(((t1 >>> 8) & 0xff)) << 8);
- u |= (sbox2(((t1 >>> 16) & 0xff)) << 16);
- u |= ((int)(SBOX1[((t1 >>> 24) & 0xff)] & 0xff) << 24);
-
- t2 = s[1] ^ skey[1 + keyoff];
- v = (int)SBOX1[(t2 & 0xff)] & 0xff;
- v |= (sbox4(((t2 >>> 8) & 0xff)) << 8);
- v |= (sbox3(((t2 >>> 16) & 0xff)) << 16);
- v |= (sbox2(((t2 >>> 24) & 0xff)) << 24);
-
- v = leftRotate(v, 8);
- u ^= v;
- v = leftRotate(v, 8) ^ u;
- u = rightRotate(u, 8) ^ v;
- s[2] ^= leftRotate(v, 16) ^ u;
- s[3] ^= leftRotate(u, 8);
-
- t1 = s[2] ^ skey[2 + keyoff];
- u = sbox4((t1 & 0xff));
- u |= sbox3(((t1 >>> 8) & 0xff)) << 8;
- u |= sbox2(((t1 >>> 16) & 0xff)) << 16;
- u |= ((int)SBOX1[((t1 >>> 24) & 0xff)] & 0xff) << 24;
-
- t2 = s[3] ^ skey[3 + keyoff];
- v = ((int)SBOX1[(t2 & 0xff)] & 0xff);
- v |= sbox4(((t2 >>> 8) & 0xff)) << 8;
- v |= sbox3(((t2 >>> 16) & 0xff)) << 16;
- v |= sbox2(((t2 >>> 24) & 0xff)) << 24;
-
- v = leftRotate(v, 8);
- u ^= v;
- v = leftRotate(v, 8) ^ u;
- u = rightRotate(u, 8) ^ v;
- s[0] ^= leftRotate(v, 16) ^ u;
- s[1] ^= leftRotate(u, 8);
- }
-
- private void init(byte[] key, boolean isEncrypt) {
- keySize = key.length;
-
- int[] k = new int[8];
- int[] ka = new int[4];
- int[] kb = new int[4];
- int[] t = new int[4];
-
- switch (key.length) {
- case 16:
- k[0] = BytesUtil.bytes2int(key, 0, true);
- k[1] = BytesUtil.bytes2int(key, 4, true);
- k[2] = BytesUtil.bytes2int(key, 8, true);
- k[3] = BytesUtil.bytes2int(key, 12, true);
- k[4] = k[5] = k[6] = k[7] = 0;
- break;
- case 24:
- k[0] = BytesUtil.bytes2int(key, 0, true);
- k[1] = BytesUtil.bytes2int(key, 4, true);
- k[2] = BytesUtil.bytes2int(key, 8, true);
- k[3] = BytesUtil.bytes2int(key, 12, true);
- k[4] = BytesUtil.bytes2int(key, 16, true);
- k[5] = BytesUtil.bytes2int(key, 20, true);
- k[6] = ~k[4];
- k[7] = ~k[5];
- break;
- case 32:
- k[0] = BytesUtil.bytes2int(key, 0, true);
- k[1] = BytesUtil.bytes2int(key, 4, true);
- k[2] = BytesUtil.bytes2int(key, 8, true);
- k[3] = BytesUtil.bytes2int(key, 12, true);
- k[4] = BytesUtil.bytes2int(key, 16, true);
- k[5] = BytesUtil.bytes2int(key, 20, true);
- k[6] = BytesUtil.bytes2int(key, 24, true);
- k[7] = BytesUtil.bytes2int(key, 28, true);
- break;
- default:
- throw new
- IllegalArgumentException("Invalid key size, only support 16/24/32 bytes");
- }
-
- for (int i = 0; i < 4; i++) {
- ka[i] = k[i] ^ k[i + 4];
- }
-
- /* compute KA */
- f2(ka, SIGMA, 0);
- for (int i = 0; i < 4; i++) {
- ka[i] ^= k[i];
- }
- f2(ka, SIGMA, 4);
-
- if (keySize == 16) {
- if (isEncrypt) {
- /* KL dependant keys */
- kw[0] = k[0];
- kw[1] = k[1];
- kw[2] = k[2];
- kw[3] = k[3];
- roldq(15, k, 0, subkey, 4);
- roldq(30, k, 0, subkey, 12);
- roldq(15, k, 0, t, 0);
- subkey[18] = t[2];
- subkey[19] = t[3];
- roldq(17, k, 0, ke, 4);
- roldq(17, k, 0, subkey, 24);
- roldq(17, k, 0, subkey, 32);
- /* KA dependant keys */
- subkey[0] = ka[0];
- subkey[1] = ka[1];
- subkey[2] = ka[2];
- subkey[3] = ka[3];
- roldq(15, ka, 0, subkey, 8);
- roldq(15, ka, 0, ke, 0);
- roldq(15, ka, 0, t, 0);
- subkey[16] = t[0];
- subkey[17] = t[1];
- roldq(15, ka, 0, subkey, 20);
- roldqo32(34, ka, 0, subkey, 28);
- roldq(17, ka, 0, kw, 4);
-
- } else { // decryption
- /* KL dependant keys */
- kw[4] = k[0];
- kw[5] = k[1];
- kw[6] = k[2];
- kw[7] = k[3];
- decroldq(15, k, 0, subkey, 28);
- decroldq(30, k, 0, subkey, 20);
- decroldq(15, k, 0, t, 0);
- subkey[16] = t[0];
- subkey[17] = t[1];
- decroldq(17, k, 0, ke, 0);
- decroldq(17, k, 0, subkey, 8);
- decroldq(17, k, 0, subkey, 0);
- /* KA dependant keys */
- subkey[34] = ka[0];
- subkey[35] = ka[1];
- subkey[32] = ka[2];
- subkey[33] = ka[3];
- decroldq(15, ka, 0, subkey, 24);
- decroldq(15, ka, 0, ke, 4);
- decroldq(15, ka, 0, t, 0);
- subkey[18] = t[2];
- subkey[19] = t[3];
- decroldq(15, ka, 0, subkey, 12);
- decroldqo32(34, ka, 0, subkey, 4);
- roldq(17, ka, 0, kw, 0);
- }
- } else { // 192bit or 256bit
- /* compute KB */
- for (int i = 0; i < 4; i++) {
- kb[i] = ka[i] ^ k[i + 4];
- }
- f2(kb, SIGMA, 8);
-
- if (isEncrypt) {
- /* KL dependant keys */
- kw[0] = k[0];
- kw[1] = k[1];
- kw[2] = k[2];
- kw[3] = k[3];
- roldqo32(45, k, 0, subkey, 16);
- roldq(15, k, 0, ke, 4);
- roldq(17, k, 0, subkey, 32);
- roldqo32(34, k, 0, subkey, 44);
- /* KR dependant keys */
- roldq(15, k, 4, subkey, 4);
- roldq(15, k, 4, ke, 0);
- roldq(30, k, 4, subkey, 24);
- roldqo32(34, k, 4, subkey, 36);
- /* KA dependant keys */
- roldq(15, ka, 0, subkey, 8);
- roldq(30, ka, 0, subkey, 20);
- /* 32bit rotation */
- ke[8] = ka[1];
- ke[9] = ka[2];
- ke[10] = ka[3];
- ke[11] = ka[0];
- roldqo32(49, ka, 0, subkey, 40);
-
- /* KB dependant keys */
- subkey[0] = kb[0];
- subkey[1] = kb[1];
- subkey[2] = kb[2];
- subkey[3] = kb[3];
- roldq(30, kb, 0, subkey, 12);
- roldq(30, kb, 0, subkey, 28);
- roldqo32(51, kb, 0, kw, 4);
-
- } else { // decryption
- /* KL dependant keys */
- kw[4] = k[0];
- kw[5] = k[1];
- kw[6] = k[2];
- kw[7] = k[3];
- decroldqo32(45, k, 0, subkey, 28);
- decroldq(15, k, 0, ke, 4);
- decroldq(17, k, 0, subkey, 12);
- decroldqo32(34, k, 0, subkey, 0);
- /* KR dependant keys */
- decroldq(15, k, 4, subkey, 40);
- decroldq(15, k, 4, ke, 8);
- decroldq(30, k, 4, subkey, 20);
- decroldqo32(34, k, 4, subkey, 8);
- /* KA dependant keys */
- decroldq(15, ka, 0, subkey, 36);
- decroldq(30, ka, 0, subkey, 24);
- /* 32bit rotation */
- ke[2] = ka[1];
- ke[3] = ka[2];
- ke[0] = ka[3];
- ke[1] = ka[0];
- decroldqo32(49, ka, 0, subkey, 4);
-
- /* KB dependant keys */
- subkey[46] = kb[0];
- subkey[47] = kb[1];
- subkey[44] = kb[2];
- subkey[45] = kb[3];
- decroldq(30, kb, 0, subkey, 32);
- decroldq(30, kb, 0, subkey, 16);
- roldqo32(51, kb, 0, kw, 0);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/ceacb982/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/CheckSumHandler.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/CheckSumHandler.java b/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/CheckSumHandler.java
deleted file mode 100644
index 7e5dada..0000000
--- a/haox-kerb/kerb-crypto/src/main/java/org/apache/kerberos/kerb/crypto/CheckSumHandler.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.crypto;
-
-import org.apache.kerberos.kerb.KrbErrorCode;
-import org.apache.kerberos.kerb.KrbException;
-import org.apache.kerberos.kerb.crypto.cksum.*;
-import org.apache.kerberos.kerb.spec.common.CheckSum;
-import org.apache.kerberos.kerb.spec.common.CheckSumType;
-import org.apache.kerberos.kerb.spec.common.KeyUsage;
-
-public class CheckSumHandler {
-
- public static CheckSumTypeHandler getCheckSumHandler(String cksumType) throws KrbException {
- CheckSumType eTypeEnum = CheckSumType.fromName(cksumType);
- return getCheckSumHandler(eTypeEnum);
- }
-
- public static CheckSumTypeHandler getCheckSumHandler(int cksumType) throws KrbException {
- CheckSumType eTypeEnum = CheckSumType.fromValue(cksumType);
- return getCheckSumHandler(eTypeEnum);
- }
-
- public static boolean isImplemented(CheckSumType cksumType) throws KrbException {
- return getCheckSumHandler(cksumType, true) != null;
- }
-
- public static CheckSumTypeHandler getCheckSumHandler(CheckSumType cksumType) throws KrbException {
- return getCheckSumHandler(cksumType, false);
- }
-
- private static CheckSumTypeHandler getCheckSumHandler(CheckSumType cksumType, boolean check) throws KrbException {
- CheckSumTypeHandler cksumHandler = null;
- switch (cksumType) {
- case CRC32:
- cksumHandler = new Crc32CheckSum();
- break;
-
- case DES_MAC:
- cksumHandler = new DesCbcCheckSum();
- break;
-
- case RSA_MD4:
- cksumHandler = new RsaMd4CheckSum();
- break;
-
- case RSA_MD5:
- cksumHandler = new RsaMd5CheckSum();
- break;
-
- case NIST_SHA:
- cksumHandler = new Sha1CheckSum();
- break;
-
- case RSA_MD4_DES:
- cksumHandler = new RsaMd4DesCheckSum();
- break;
-
- case RSA_MD5_DES:
- cksumHandler = new RsaMd5DesCheckSum();
- break;
-
- case HMAC_SHA1_DES3:
- case HMAC_SHA1_DES3_KD:
- cksumHandler = new HmacSha1Des3CheckSum();
- break;
-
- case HMAC_SHA1_96_AES128:
- cksumHandler = new HmacSha1Aes128CheckSum();
- break;
-
- case HMAC_SHA1_96_AES256:
- cksumHandler = new HmacSha1Aes256CheckSum();
- break;
-
- case CMAC_CAMELLIA128:
- cksumHandler = new CmacCamellia128CheckSum();
- break;
-
- case CMAC_CAMELLIA256:
- cksumHandler = new CmacCamellia256CheckSum();
- break;
-
- case HMAC_MD5_ARCFOUR:
- cksumHandler = new HmacMd5Rc4CheckSum();
- break;
-
- case MD5_HMAC_ARCFOUR:
- cksumHandler = new Md5HmacRc4CheckSum();
- break;
-
- default:
- break;
- }
-
- if (cksumHandler == null && ! check) {
- String message = "Unsupported checksum type: " + cksumType.name();
- throw new KrbException(KrbErrorCode.KDC_ERR_SUMTYPE_NOSUPP, message);
- }
-
- return cksumHandler;
- }
-
- public static CheckSum checksum(CheckSumType checkSumType, byte[] bytes) throws KrbException {
- CheckSumTypeHandler handler = getCheckSumHandler(checkSumType);
- byte[] checksumBytes = handler.checksum(bytes);
- CheckSum checkSum = new CheckSum();
- checkSum.setCksumtype(checkSumType);
- checkSum.setChecksum(checksumBytes);
- return checkSum;
- }
-
- public static boolean verify(CheckSum checkSum, byte[] bytes) throws KrbException {
- CheckSumType checkSumType = checkSum.getCksumtype();
- CheckSumTypeHandler handler = getCheckSumHandler(checkSumType);
- return handler.verify(bytes, checkSum.getChecksum());
- }
-
- public static CheckSum checksumWithKey(CheckSumType checkSumType,
- byte[] bytes, byte[] key, KeyUsage usage) throws KrbException {
- CheckSumTypeHandler handler = getCheckSumHandler(checkSumType);
- byte[] checksumBytes = handler.checksumWithKey(bytes, key, usage.getValue());
- CheckSum checkSum = new CheckSum();
- checkSum.setCksumtype(checkSumType);
- checkSum.setChecksum(checksumBytes);
- return checkSum;
- }
-
- public static boolean verifyWithKey(CheckSum checkSum, byte[] bytes,
- byte[] key, KeyUsage usage) throws KrbException {
- CheckSumType checkSumType = checkSum.getCksumtype();
- CheckSumTypeHandler handler = getCheckSumHandler(checkSumType);
- return handler.verifyWithKey(bytes, key,
- usage.getValue(), checkSum.getChecksum());
- }
-}